Doesn't Contain Loops or Multiple Edges

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

문제

Coloring of a labeled undirected graph with nn vertices in kk colors is an assignment of colors to its vertices, such that each vertex receives an integer color xx (1xk1 \leq x \leq k) and no two adjacent vertices have the same color. A coloring can be treated as an array of integers from 11 to kk of length nn, ii-th element of which corresponds to the color of the ii-th vertex of the graph.

Coloring bb is monotonic to coloring aa of the same graph if \uline{exactly} one of the following statements holds:

  1. _1ina_ib_i\forall\_{1 \leq i \leq n} a\_i \leq b\_i
  2. _1ina_ib_i\forall\_{1 \leq i \leq n} a\_i \geq b\_i

Note that a coloring is not monotonic to itself because in that case both statements above hold.

You are given a labeled undirected graph and its coloring aa in kk colors. Is there a coloring bb of the given graph in kk colors which is monotonic to aa?

입력

The first line contains three integers nn, mm and kk (1n,m,k31051 \leq n, m, k \leq 3 \cdot 10^5), the number of vertices in the graph, the number of the edges in the graph and the number of colors, respectively.

The second line contains nn integers a_ia\_i (1c_ik1 \leq c\_i \leq k), the colors of vertices. 

mm lines follow. ii-th of them contains two integers u_iu\_i and v_iv\_i (1u_i<v_in1 \leq u\_i < v\_i \leq n), describing an edge between vertices u_iu\_i and v_iv\_i.

The graph doesn't contain loops or multiple edges. It is guaranteed that the array aa describes a valid coloring of the given graph.

출력

Print 1 if there exists a coloring bb monotonic to aa and print 0 otherwise.