PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SP0000072. Tô màu các hợp số (Composite Coloring)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Tô màu các hợp số (Composite Coloring)

Composite Coloring

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

You are given nn composite integers a1,a2,…,ana_1,a_2,\ldots,a_n. Choose mm colors (1≤m≤111\le m\le11) and assign each position ii a color cic_i from 11 through mm. Every color must be used at least once. Whenever two positions have the same color, the greatest common divisor of their values must be greater than 11. You need not minimize the number of colors; any valid coloring using at most 1111 colors is accepted.

Input

The first line contains nn. The second line contains exactly nn composite integers a1,a2,…,ana_1,a_2,\ldots,a_n in order.

Output

Print mm on the first line and nn space-separated colors c1,c2,…,cnc_1,c_2,\ldots,c_n on the second. Every color 1,2,…,m1,2,\ldots,m must appear, and every pair of values assigned the same color must have GCD greater than 11.

Subtasks

  • Subtask 1 (20 points): 1≤n≤301\le n\le 30; 4≤ai≤10004\le a_i\le1000 for every 1≤i≤n1\le i\le n; all aia_i are composite.
  • Subtask 2 (30 points): 1≤n≤2001\le n\le 200; 4≤ai≤10004\le a_i\le1000 for every 1≤i≤n1\le i\le n; all aia_i are composite.
  • Subtask 3 (50 points): 1≤n≤10001\le n\le 1000; 4≤ai≤10004\le a_i\le1000 for every 1≤i≤n1\le i\le n; all aia_i are composite.

Examples

Input

3
6 10 15

Output

1
1 1 1

Explanation

The composite values are 6,10,156,10,15. We can use one color, assigning c1=c2=c3=1c_1=c_2=c_3=1, because gcd⁡(6,10)=2\gcd(6,10)=2, gcd⁡(6,15)=3\gcd(6,15)=3, and gcd⁡(10,15)=5\gcd(10,15)=5, all greater than 11. Hence printing 1 and 1 1 1 is valid. Other valid colorings are also accepted.