Colourings

아직 제출이 없습니다시간 제한2초메모리 제한256 MB

문제

Let G=(V,E)G=(V,E) be an undirected graph. We call a function c:VNc:V\to\mathbb{N} a colouring if for each edge (u,v)E(u,v)\in E, we have c(u)c(v)c(u)\neq c(v).

We shall call a colouring cc beautiful if for every vVv\in V, we have c(v)1,2,,kc(v)\in\\{1,2,\ldots,k\\}. In other words, a colouring cc is beautiful, if only colours that are numbers from 11 to kk are used.

We shall call a colouring cc smart if for every vVv\in V, there is a vertex wVw\in V, wvw\neq v, such that c(v)=c(w)c(v)=c(w). In other words, a colouring cc is smart if every used colour is used at least twice.

Byteasar is looking for a suitable colouring for his graph. He has already found a beautiful colouring c_bc\_b, but it seemed too simple and not ambitious enough. Another time, he managed to find a smart colouring c_sc\_s, but after a while he could not stand to look at it any longer.

Byteasar lost hope that, on his way, he will meet a colouring beautiful and smart at the same time. Can you surprise him and find such a colouring?

입력

The first line of input contains three integers nn, mm, kk (1kn200,0001\leq k \leq n \leq 200\\,000, 0m200,0000 \leq m \leq 200\\,000). Number kk describes which colourings are considered beautiful, while nn and mm are the numbers of vertices and edges of Byteasar's graph, respectively. Graph's vertices are numbered 11 through nn.

The following mm lines describe the edges of Byteasar's graph. The ii-th of these lines contain two integers u_i,v_iu\_i, v\_i (1u_i\<v_in1\leq u\_i\<v\_i\leq n) indicating that the vertices numbered u_iu\_i and v_iv\_i are connected by an edge. The pairs (u_i,v_i)(u\_i,v\_i) are distinct.

The next two lines contain descriptions of the colourings c_bc\_b and c_sc\_s, in that order. Colouring descriptions comprise nn positive integers not greater than nn: ii-th of these numbers is the colour of the vertex ii. The colouring c_bc\_b is beautiful, whereas the colouring c_sc\_s is smart.

출력

If there exists a graph colouring which is both smart and beautiful, your program should output the word "TAK" (Polish for yes) in the first line. The second line should contain nn integers describing any such colouring. The description should be in the same format as the description of the colourings in the input.

If no such colouring exists, the only line of the output should contain the word "NIE" (Polish for no).