{"problem":{"name":"D. Secure but True","description":{"content":"Since both Nicole and Noura are admins for the ACPC page, they need to agree on a secure and easy way to exchange password information whenever one of the admins changes it, therefore, Nicole suggeste","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10108D"},"statements":[{"statement_type":"Markdown","content":"Since both Nicole and Noura are admins for the ACPC page, they need to agree on a secure and easy way to exchange password information whenever one of the admins changes it, therefore, Nicole suggested the following technique for doing it:\n\nLet L be the list of all strings that contain only mirrored letters {A, H, I, M, O, T, U, V, W, X, Y}, sorted by their length. If two strings have the same length, they are sorted according to the alphabetical order.\n\nHelp Nicole and Noura by writing a program that finds the new password. Given a string S that contains only mirrored letters, the new password is the string in L that is located after the string S by K.\n\nThe first line of input contains an integer T (1 ≤ T ≤ 256), the number of test cases.\n\nEach test case will consist of an integer K (1 ≤ K ≤ 109), followed by the string S (1 ≤ |S| ≤ 103).\n\n|S| represents the length of the string S.\n\nFor each test case, print the new password on a single line.\n\nWarning: large Input/Output data, be careful with certain languages.\n\n## Input\n\nThe first line of input contains an integer T (1 ≤ T ≤ 256), the number of test cases.Each test case will consist of an integer K (1 ≤ K ≤ 109), followed by the string S (1 ≤ |S| ≤ 103).|S| represents the length of the string S.\n\n## Output\n\nFor each test case, print the new password on a single line.\n\n[samples]\n\n## Note\n\nWarning: large Input/Output data, be careful with certain languages.","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $\\Sigma = \\{A, H, I, M, O, T, U, V, W, X, Y\\}$ be the set of mirrored letters, ordered alphabetically:  \n$$ \\Sigma = [\\sigma_0, \\sigma_1, \\dots, \\sigma_{10}] = [A, H, I, M, O, T, U, V, W, X, Y] $$  \nLet $L$ be the infinite lexicographically ordered list of all finite-length strings over $\\Sigma$, sorted first by length (ascending), then lexicographically within each length.\n\n**Given**  \nFor each test case:  \n- $K \\in \\mathbb{Z}$, $1 \\leq K \\leq 10^9$  \n- $S \\in \\Sigma^*$, a non-empty string of length $|S| \\leq 1000$\n\n**Objective**  \nFind the string $P \\in L$ such that $P$ is the $K$-th string after $S$ in $L$, i.e., if $S$ is at position $i$ in $L$, then $P$ is at position $i + K$.  \n\nOutput $P$.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10108D","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}