CF1925A.We Got Everything Covered!

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

We Got Everything Covered!

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.

Input

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).

Output

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.

Note

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}: {\color{red}{\texttt{a}}}\texttt{b
  • 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}: {\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}: \texttt{b}{\color{red}{\texttt{aa}}}\texttt{b
  • ab}: \texttt{ba}{\color{red}{\texttt{ab}}
  • ba}: {\color{red}{\texttt{ba}}}\texttt{ab
  • 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}: {\color{red}{\texttt{a}}}\texttt{bcb}{\color{red}{\texttt{a}}}\texttt{c
  • ab}: {\color{red}{\texttt{ab}}}\texttt{cbac
  • ac}: \texttt{abcb}{\color{red}{\texttt{ac}}
  • ba}: \texttt{abc}{\color{red}{\texttt{ba}}}\texttt{c
  • bb}: \texttt{a}{\color{red}{\texttt{b}}}\texttt{c}{\color{red}{\texttt{b}}}\texttt{ac
  • bc}: \texttt{a}{\color{red}{\texttt{bc}}}\texttt{bac
  • ca}: \texttt{ab}{\color{red}{\texttt{c}}}\texttt{b}{\color{red}{\texttt{a}}}\texttt{c
  • cb}: \texttt{ab}{\color{red}{\texttt{cb}}}\texttt{ac
  • cc}: \texttt{ab}{\color{red}{\texttt{c}}}\texttt{ba}{\color{red}{\texttt{c}}

Samples

4
1 2
2 1
2 2
2 3
ab
aa
baab
abcbac

在线编程 IDE

建议全屏模式获得最佳体验