Railway Siding

No attempts yetTime limit1sMemory limit128 MB

Problem

A railway siding has two dead-end sidetracks, numbered 11 and 22. Cars enter the siding from track A and leave it on track B.

Railway siding with track A entering and track B leaving, and two dead-end sidetracks 1 and 2

There are nn cars on track A, numbered 11 to nn. They enter the siding in the order a1,a2,,ana_1, a_2, \dots, a_n. We want them to leave on track B in the order 1,2,,n1, 2, \dots, n.

Each car is moved once from track A onto sidetrack 11 or 22, and later moved once from that sidetrack onto track B. A sidetrack behaves like a stack: the car placed on it most recently is the first one that can be removed. The sidetracks are long enough to hold any number of cars, so their capacity is never a concern.

Cars leave track A strictly in the order a1,a2,,ana_1, a_2, \dots, a_n, but you may move a car from a sidetrack to track B at any moment, including between the arrivals of later cars. Decide whether the cars can be reordered into 1,2,,n1, 2, \dots, n on track B, and if so, choose which sidetrack each car is placed on.

Input

The first line contains one integer nn (1n10001 \le n \le 1000), the number of cars.

The second line contains a1,a2,,ana_1, a_2, \dots, a_n, a permutation of 1,2,,n1, 2, \dots, n, separated by single spaces.

Output

If the cars cannot be rearranged into the order 1,2,,n1, 2, \dots, n on track B, print a single line containing the word NIE (meaning it is impossible).

Otherwise, print TAK (meaning it is possible) on the first line. On the second line print nn integers separated by single spaces: the ii-th integer is the sidetrack (11 or 22) onto which car aia_i is moved.

If more than one valid assignment exists, print the lexicographically smallest one: compare two assignment sequences position by position from left to right, and prefer the one with the smaller sidetrack number at the first position where they differ.

Hint

Take the sequence a=[1,3,4,2]a = [1, 3, 4, 2]. Move car 11 onto sidetrack 11 and immediately move it to track B. Move car 33 onto sidetrack 11, then car 44 onto sidetrack 22. Finally move car 22 onto sidetrack 11; now cars 22 and then 33 leave sidetrack 11 onto track B, followed by car 44 from sidetrack 22. Track B receives 1,2,3,41, 2, 3, 4 in order, and the sidetrack choices are 1 1 2 11\ 1\ 2\ 1.