{"problem":{"name":"E. Playing with numbers","description":{"content":"Folan and Eltan are brothers. However, as all brothers are, they always fight. One day their mom had to go to work, so she decided to give them a task to keep them busy while she is away. She gave th","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":2000,"memory_limit":65536},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10106E"},"statements":[{"statement_type":"Markdown","content":"Folan and Eltan are brothers. However, as all brothers are, they always fight. One day their mom had to go to work, so she decided to give them a task to keep them busy while she is away.\n\nShe gave them two numbers S and N.\n\nShe told Folan that he has to delete exactly N digits from the number S, so that the resulting number is as *small* as possible.\n\nThen, she told Eltan that he has to delete exactly N digits from the number S, so that the resulting number is as *big* as possible.\n\nFolan and Eltan are ex ACMers. They decided to write a program to solve this problem, so they can go back to fighting again.\n\nWhen their mom heard the evil plan, she decided to make the number S very big, and she may have added leading zeros to it.\n\nThe boys were really upset because they couldn't find a way to write a program that would solve this problem fast enough before their mom returns, so they asked for your help.\n\nCan you help them with this program, so they can go back to fighting again?\n\nThe first line of the input consists of a single integer t, the number of test cases. Each test case consists of two numbers S and N separated by a single space. where (0 ≤ S < 10100000) and it may contain leading zeros, and (0 ≤ N < |S|).\n\nNote that |S| means the length of the number S.\n\nFor each test case, print two lines.\n\nThe first line should contain the *smallest* number Folan can get after deleting exactly N digits from S.\n\nThe second line should contain the *biggest* number Eltan can get after deleting exactly N digits from S.\n\nPlease note that in case some of the leading zeros were not deleted, you have to print the resulting number with the remaining leading zeros.\n\n## Input\n\nThe first line of the input consists of a single integer t, the number of test cases. Each test case consists of two numbers S and N separated by a single space. where (0 ≤ S < 10100000) and it may contain leading zeros, and (0 ≤ N < |S|).Note that |S| means the length of the number S.\n\n## Output\n\nFor each test case, print two lines.The first line should contain the *smallest* number Folan can get after deleting exactly N digits from S.The second line should contain the *biggest* number Eltan can get after deleting exactly N digits from S.Please note that in case some of the leading zeros were not deleted, you have to print the resulting number with the remaining leading zeros.\n\n[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ N, M \\in \\mathbb{Z}_{\\geq 0} $.  \nLet $ H = \\{h_1, h_2, \\dots, h_N\\} $ be a set of horrible words over alphabet $ \\Sigma = \\{a, b, c, d, e, f, g, h, i, j\\} $.  \nLet $ K = \\{k_1, k_2, \\dots, k_M\\} $ be a set of kind words over $ \\Sigma $.  \n\n**Constraints**  \n1. No word in $ K $ may be a contiguous substring of the output string.  \n2. Every word in $ H $ must be a contiguous substring of the output string.  \n3. The output string must be over $ \\Sigma $.  \n\n**Objective**  \nFind the lexicographically smallest string $ s \\in \\Sigma^* $ such that:  \n- $ \\forall h \\in H, \\, h \\text{ is a substring of } s $,  \n- $ \\forall k \\in K, \\, k \\text{ is not a substring of } s $.  \n\nIf no such $ s $ exists, output `\"-\"`.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10106E","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}