{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e给定整数 $$$n$$$ ($$$n \u0026gt; 2$$$),让我们按字典顺序(按字母顺序)编写长度为 $$$n$$$ 的所有包含 $$$n-2$$$ 个字母 \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003ea\u003c/span\u003e\u0027 和两个字母 \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003eb\u003c/span\u003e\u0027 的字符串。\u003c/p\u003e\u003cp\u003e回想一下,长度为 $$$n$$$ 的字符串 $$$s$$$ 按字典顺序小于长度为 $$$n$$$ 的字符串 $$$t$$$,如果存在这样的 $$$i$$$ ($$$1 \\le i \\le n$$$),使得 $$$s_i \u0026lt; t_i$$$,对于任何 $$$j$$$ ($$$1 \\le j \u0026lt; i$$$) $$$s_j \u003d t_j$$$。字符串的字典比较是由现代编程语言中的运算符 \u003cspan class\u003d\"tex-font-style-tt\"\u003e\u0026lt;\u003c/span\u003e 实现的。\u003c/p\u003e\u003cp\u003e例如,如果 $$$n\u003d5$$$ 字符串是(顺序很重要):\u003c/p\u003e\u003col\u003e \u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003eaaabb\u003c/span\u003e \u003c/li\u003e\u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003eaabab\u003c/span\u003e \u003c/li\u003e\u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003eaabba\u003c/span\u003e \u003c/li\u003e\u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003eabaab\u003c/span\u003e \u003c/li\u003e\u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003eababa\u003c/span\u003e \u003c/li\u003e\u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003eabbaa\u003c/span\u003e \u003c/li\u003e\u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003ebaaab\u003c/span\u003e \u003c/li\u003e\u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003ebaaba\u003c/span\u003e \u003c/li\u003e\u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003ebabaa\u003c/span\u003e \u003c/li\u003e\u003cli\u003e \u003cspan class\u003d\"tex-font-style-tt\"\u003ebbaaa\u003c/span\u003e \u003c/li\u003e\u003c/ol\u003e\u003cp\u003e很容易证明,这样的字符串列表将包含确切的 $$$\\frac{n \\cdot (n-1)}{2}$$$ 个字符串。\u003c/p\u003e\u003cp\u003e给定 $$$n$$$ ($$$n \u0026gt; 2$$$) 和 $$$k$$$ ($$$1 \\le k \\le \\frac{n \\cdot (n-1)}{2}$$$)。打印列表中第 $$$k$$$ 个字符串。\u003c/p\u003e"}},{"title":"输入","value":{"format":"HTML","content":"\u003cp\u003e输入包含一个或多个测试用例。\u003c/p\u003e\u003cp\u003e第一行包含一个整数 $$$t$$$ ($$$1 \\le t \\le 10^4$$$) —— 测试中的测试用例数。然后是 $$$t$$$ 个测试用例。\u003c/p\u003e\u003cp\u003e每个测试用例写在单独的一行中,包含两个整数 $$$n$$$ 和 $$$k$$$ ($$$3 \\le n \\le 10^5, 1 \\le k \\le \\min(2\\cdot10^9, \\frac{n \\cdot (n-1)}{2})$$$。\u003c/p\u003e\u003cp\u003e测试中所有测试用例中的值 $$$n$$$ 的总和不超过 $$$10^5$$$。\u003c/p\u003e"}},{"title":"输出","value":{"format":"HTML","content":"\u003cp\u003e对于每个测试用例,打印出长度为 $$$n$$$ 的所有上述字符串列表中的第 $$$k$$$ 个字符串。列表中的字符串按字典顺序排序。\u003c/p\u003e"}},{"title":"示例 1","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e7\n5 1\n5 2\n5 8\n5 10\n3 1\n3 2\n20 100\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eaaabb\naabab\nbaaba\nbbaaa\nabb\nbab\naaaaabaaaaabaaaaaaaa\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}}]}