Codeforces Round 949 (Div. 2)
D
Turtle and Multiplication
Codeforces
2400
原题
← CE →
翻译中…

Turtle just learned how to multiply two integers in his math class, and he was very excited.

翻译中…

Then Piggy gave him an integer $n$, and asked him to construct a sequence $a_1, a_2, \ldots, a_n$ consisting of integers which satisfied the following conditions:

翻译中…
  • For all $1 \le i \le n$, $1 \le a_i \le 3 \cdot 10^5$.
  • For all $1 \le i \lt j \le n - 1$, $a_i \cdot a_{i + 1} \ne a_j \cdot a_{j + 1}$.
翻译中…

Of all such sequences, Piggy asked Turtle to find the one with the minimum number of distinct elements.

翻译中…

Turtle definitely could not solve the problem, so please help him!

翻译中…

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 first line of each test case contains a single integer $n$ ($2 \le n \le 10^6$) — the length of the sequence $a$.

翻译中…

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

翻译中…

Output

翻译中…

For each test case, output $n$ integers $a_1, a_2, \ldots, a_n$ — the elements of the sequence $a$.

翻译中…

If there are multiple answers, print any of them.

翻译中…

Note

翻译中…

In the third test case, $a = [3, 4, 2, 6]$ violates the second condition since $a_1 \cdot a_2 = a_3 \cdot a_4$. $a = [2, 3, 4, 4]$ satisfy the conditions but its number of distinct elements isn't minimum.

翻译中…

样例

Input #1
3
2
3
4
Output #1
114514 114514
1 2 2
3 3 4 4
InputCopy OutputCopy
题目信息
题号
1981D
时间限制
3 s
内存限制
512 MB
标签
构造
DFS 及类似
图论
数论

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