Codeforces Round 884 (Div. 1 + Div. 2)
D
Row Major
Codeforces
1400
原题
← CE →
翻译中…

The row-major order of an $r \times c$ grid of characters $A$ is the string obtained by concatenating all the rows, i.e. $$ A_{11}A_{12} \dots A_{1c}A_{21}A_{22} \dots A_{2c} \dots A_{r1}A_{r2} \dots A_{rc}. $$

翻译中…

A grid of characters $A$ is bad if there are some two adjacent cells (cells sharing an edge) with the same character.

翻译中…

You are given a positive integer $n$. Consider all strings $s$ consisting of only lowercase Latin letters such that they are not the row-major order of any bad grid. Find any string with the minimum number of distinct characters among all such strings of length $n$.

翻译中…

It can be proven that at least one such string exists under the constraints of the problem.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.

翻译中…

The only line of each test case contains a single integer $n$ ($1 \le n \le 10^6$).

翻译中…

It is guaranteed that the sum of $n$ over all test cases does not exceed $10^6$.

翻译中…

Output

翻译中…

For each test case, output a string with the minimum number of distinct characters among all suitable strings of length $n$.

翻译中…

If there are multiple solutions, print any of them.

翻译中…

Note

翻译中…

In the first test case, there are $3$ ways $s$ can be the row-major order of a grid, and they are all not bad:

翻译中…
t t h t h a t
h a t
a
t
翻译中…

It can be proven that $3$ distinct characters is the minimum possible.

翻译中…

In the second test case, there are $2$ ways $s$ can be the row-major order of a grid, and they are both not bad:

翻译中…
i i s
s
翻译中…

It can be proven that $2$ distinct characters is the minimum possible.

翻译中…

In the third test case, there is only $1$ way $s$ can be the row-major order of a grid, and it is not bad.

翻译中…

In the fourth test case, there are $4$ ways $s$ can be the row-major order of a grid, and they are all not bad:

翻译中…
t t o t o m t o m a t o
o m a a t o
m t o
a
t
o
翻译中…

It can be proven that $4$ distinct characters is the minimum possible. Note that, for example, the string "

翻译中…

orange

翻译中…

" is not an acceptable output because it has $6 \gt 4$ distinct characters, and the string "

翻译中…

banana

翻译中…

" is not an acceptable output because it is the row-major order of the following bad grid:

翻译中…
b a
n a
n a
翻译中…

样例

Input #1
4
4
2
1
6
Output #1
that
is
a
tomato
InputCopy OutputCopy
题目信息
题号
1844D
时间限制
2 s
内存限制
256 MB
标签
构造
贪心
数学
数论
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。