New Level

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

문제

Robocity has nn crossroads connected by bidirectional roads. There are mm roads in total, and all crossroads are reachable from each other. There is a level assigned to each crossroad specified by a number from 11 to kk, inclusive. Any pair of crossroads directly connected by a road has distinct levels.

The city leaders are planning a reform. Namely, they want to assign new levels to crossroads, so that each level still has a value from 11 to kk, connected crossroads would have different levels, and an additional condition has to be met: for each pair of crossroads uu and vv there must exist a path between them, such that any two adjacent crossroads along it have levels that differ by 11 modulo kk

Formally, for each pair of crossroads (u,v)(u, v) there should exist a sequence of crossroads p_1,,p_lp\_1, \ldots, p\_l, such that:

  • p_1=up\_1=u;
  • p_l=vp\_l=v;
  • for each ii from 11 to l1l-1, crossroads p_ip\_i and p_i+1p\_{i+1} are connected, and either their levels differ by one, or one of them has level of 11 and another has level of kk.

Robocity government is convinced that such level assignment exists and asks you to find it.

입력

The first line contains three integers nn, mm, kk (1n,m,k5000001 \le n, m, k \le 500000), number of crossroads, roads, and levels.

The second line contains nn integers c_1,c_2,,c_nc\_1, c\_2, \ldots, c\_n (1c_ik1 \le c\_i \le k), c_ic\_i is the level of the crossroad ii.

Then mm lines follow, each of them contains two integers uu, vv (1u,vn,uv1 \le u, v \le n, u \neq v), a pairs of crossroads connected by a road.

It is guaranteed that there are no two roads connecting the same pair of crossroads, and that there exists a path between each pair of crossroads.

출력

Output nn integers d_1,d_2,,d_nd\_1, d\_2, \ldots, d\_n (1d_ik1 \le d\_i \le k), the levels of the crossroads in the new assignment.