Divisible Array solution codeforces

Divisible Array solution codeforces

You are given a positive integer 𝑛. Please find an array 𝑎1,𝑎2,,𝑎𝑛�1,�2,…,�� that is perfect.

A perfect array 𝑎1,𝑎2,,𝑎𝑛�1,�2,…,�� satisfies the following criteria:

  • 1𝑎𝑖10001≤��≤1000 for all 1𝑖𝑛1≤�≤�.
  • 𝑎𝑖�� is divisible by 𝑖 for all 1𝑖𝑛1≤�≤�.
  • 𝑎1+𝑎2++𝑎𝑛�1+�2+…+�� is divisible by 𝑛.
Input

Each test contains multiple test cases. The first line contains the number of test cases 𝑡 (1𝑡2001≤�≤200). The description of the test cases follows.

The only line of each test case contains a single positive integer 𝑛 (1𝑛2001≤�≤200) — the length of the array 𝑎.

Divisible Array solution codeforces

For each test case, output an array 𝑎1,𝑎2,,𝑎𝑛�1,�2,…,�� that is perfect.

We can show that an answer always exists. If there are multiple solutions, print any.

Example

input

Copy
7
1
2
3
4
5
6
7

output

Copy
1
2 4
1 2 3
2 8 6 4
3 4 9 4 5
1 10 18 8 5 36
3 6 21 24 10 6 14
Note

In the third test case:

  • 𝑎1=1�1=1 is divisible by 11.
  • 𝑎2=2�2=2 is divisible by 22.
  • 𝑎3=3�3=3 is divisible by 33.
  • 𝑎1+𝑎2+𝑎3=1+2+3=6�1+�2+�3=1+2+3=6 is divisible by 33.

In the fifth test case:

  • 𝑎1=3�1=3 is divisible by 11.
  • 𝑎2=4�2=4 is divisible by 22.
  • 𝑎3=9�3=9 is divisible by 33.
  • 𝑎4=4�4=4 is divisible by 44.
  • 𝑎5=5�5=5 is divisible by 55.
  • 𝑎1+𝑎2+𝑎3+𝑎4+𝑎5=3+4+9+4+5=25�1+�2+�3+�4+�5=3+4+9+4+5=25 is divisible by 55.

Leave a Reply

Your email address will not be published. Required fields are marked *