PivotOJ

Hop

시간 제한: 1000ms메모리 제한: 512MB출처: COCI 2020-2021BOJ 20662

문제

♪ Jeremiah was a bullfrog Was a good friend of mine ♪

There are n water lilies, numbered 11 through nn, in a line. On the ii-th lily there is a positive integer xix_i, and the sequence (x_i)_{1 ≤ i ≤ n} is strictly increasing.

Enter three frogs.

Every pair of water lilies (a,b)(a, b), where a<ba < b, must belong to frog 11, frog 22, or frog 33.

A frog can hop from water lily ii to water lily j>ij > i if the pair (i,j)(i, j) belongs to it, and xix_i divides xjx_j.

Distribute the pairs among the frogs such that no frog can make more than 33 consecutive hops.

입력

The first line contains a positive integer nn (1 &le; n &le; 1000), the number of water lilies.

The second line contains nn positive integers xix_i (1 &le; x_i &le; 10^{18}), the numbers on the water lilies.

출력

Output n1n - 1 lines. In the ii-th line, output ii numbers, where the jj-th number is the label of the frog to which (j,i+1)(j, i + 1) belongs.

힌트

Clarification of the first example:

The frogs are marked blue (1), green (2), and red (3).

The blue frog can hop from water lily x1=3x_1 = 3 to water lily x4=9x_4 = 9, then to water lily x7=36x_7 = 36, and then to x8=72x_8 = 72. These are the only three consecutive hops any frog can make.

The green frog can hop from water lily x2=4x_2 = 4 to water lily x5=12x_5 = 12, and then to x7=36x_7 = 36, because 44 divides 1212, and 1212 divides 3636. Those are two consecutive hops.

The red frog cannot hop from water lily x2=4x_2 = 4 to water lily x3=6x_3 = 6 because 66 is not divisible by 44.

No frog can make more than three consecutive hops.

예제

예제 1

입력
8
3 4 6 9 12 18 36 72
출력
1
2 3
1 2 3
1 2 3 1
2 3 1 2 3
1 2 3 1 2 3
1 2 3 1 2 3 1

예제 2

입력
2
10 101
출력
1
코드를 제출하려면 로그인하세요.