시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 256 MB 5 2 2 40.000%

문제

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

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

We shall call a colouring $c$ smart if for every $v\in V$, there is a vertex $w\in V$, $w\neq v$, such that $c(v)=c(w)$. In other words, a colouring $c$ 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_b$, but it seemed too simple and not ambitious enough. Another time, he managed to find a smart colouring $c_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 $n$, $m$, $k$ ($1\leq k \leq n \leq 200\,000$, $0 \leq m \leq 200\,000$). Number $k$ describes which colourings are considered beautiful, while $n$ and $m$ are the numbers of vertices and edges of Byteasar's graph, respectively. Graph's vertices are numbered $1$ through $n$.

The following $m$ lines describe the edges of Byteasar's graph. The $i$-th of these lines contain two integers $u_i, v_i$ ($1\leq u_i<v_i\leq n$) indicating that the vertices numbered $u_i$ and $v_i$ are connected by an edge. The pairs $(u_i,v_i)$ are distinct.

The next two lines contain descriptions of the colourings $c_b$ and $c_s$, in that order. Colouring descriptions comprise $n$ positive integers not greater than $n$: $i$-th of these numbers is the colour of the vertex $i$. The colouring $c_b$ is beautiful, whereas the colouring $c_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 $n$ 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).

예제 입력 1

8 7 3
1 2
2 3
3 4
1 5
1 6
1 7
1 8
1 2 3 2 2 2 2 2
1 2 4 1 2 3 4 3

예제 출력 1

TAK
1 2 3 1 2 2 3 2