CF1925A.We Got Everything Covered!

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given two positive integers nn and kk .

Your task is to find a string ss such that all possible strings of length nn that can be formed using the first kk lowercase English alphabets occur as a subsequence of ss .

If there are multiple answers, print the one with the smallest length. If there are still multiple answers, you may print any of them.

Note: A string aa is called a subsequence of another string bb if aa can be obtained by deleting some (possibly zero) characters from bb without changing the order of the remaining characters.

输入格式

The first line of input contains a single integer tt ( 1t6761\leq t\leq 676 ) denoting the number of test cases.

Each test case consists of a single line of input containing two integers nn ( 1n261\leq n\leq 26 ) and kk ( 1k261\leq k\leq 26 ).

输出格式

For each test case, print a single line containing a single string ss which satisfies the above property. If there are multiple answers, print the one with the smallest length. If there are still multiple answers, you may print any of them.

输入输出样例

  • 输入#1

    4
    1 2
    2 1
    2 2
    2 3

    输出#1

    ab
    aa
    baab
    abcbac

说明/提示

For the first test case, there are two strings of length 11 which can be formed using the first 22 lowercase English alphabets, and they are present in ss as a subsequence as follows:

  • a:ab\texttt{a}: {\color{red}{\texttt{a}}}\texttt{b}
  • b:ab\texttt{b}: \texttt{a}{\color{red}{\texttt{b}}}

For the second test case, there is only one string of length 22 which can be formed using the first lowercase English alphabet, and it is present in ss as a subsequence as follows:

  • aa:aa\texttt{aa}: {\color{red}{\texttt{aa}}}

For the third test case, there are 44 strings of length 22 which can be formed using the first 22 lowercase English alphabets, and they are present in ss as a subsequence as follows:

  • aa:baab\texttt{aa}: \texttt{b}{\color{red}{\texttt{aa}}}\texttt{b}
  • ab:baab\texttt{ab}: \texttt{ba}{\color{red}{\texttt{ab}}}
  • ba:baab\texttt{ba}: {\color{red}{\texttt{ba}}}\texttt{ab}
  • bb:baab\texttt{bb}: {\color{red}{\texttt{b}}}\texttt{aa}{\color{red}{\texttt{b}}}

For the fourth test case, there are 99 strings of length 22 which can be formed using the first 33 lowercase English alphabets, and they are present in ss as a subsequence as follows:

  • aa:abcbac\texttt{aa}: {\color{red}{\texttt{a}}}\texttt{bcb}{\color{red}{\texttt{a}}}\texttt{c}
  • ab:abcbac\texttt{ab}: {\color{red}{\texttt{ab}}}\texttt{cbac}
  • ac:abcbac\texttt{ac}: \texttt{abcb}{\color{red}{\texttt{ac}}}
  • ba:abcbac\texttt{ba}: \texttt{abc}{\color{red}{\texttt{ba}}}\texttt{c}
  • bb:abcbac\texttt{bb}: \texttt{a}{\color{red}{\texttt{b}}}\texttt{c}{\color{red}{\texttt{b}}}\texttt{ac}
  • bc:abcbac\texttt{bc}: \texttt{a}{\color{red}{\texttt{bc}}}\texttt{bac}
  • ca:abcbac\texttt{ca}: \texttt{ab}{\color{red}{\texttt{c}}}\texttt{b}{\color{red}{\texttt{a}}}\texttt{c}
  • cb:abcbac\texttt{cb}: \texttt{ab}{\color{red}{\texttt{cb}}}\texttt{ac}
  • cc:abcbac\texttt{cc}: \texttt{ab}{\color{red}{\texttt{c}}}\texttt{ba}{\color{red}{\texttt{c}}}
首页