Parity Scam

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

문제

This is an interactive problem.

Pavel is a famous prosecutor. Throughout his career, he had convicted a lot of scammers, money-launderers and other criminals who plagued the city of Baǵel. Recently a major scam scheme was uncovered. The scammers had a connected undirected graph G=V,EG = \langle V,E \rangle with maximum vertex degree at most 1010, and a function f:V0,1f: V \to \\{0,1\\}. They have suggested people to try find a function g:E0,1g: E \to \\{0,1\\} such that, for every vVv \in V, the equality _eI(v)g(e)=f(v)\bigoplus\limits\_{e \in I(v)} g(e) = f(v) holds. Here, I(v)I(v) is the set of edges of GG incident to vv, and \oplus is sum modulo 22.

Pavel has quickly noticed that _vVf(v)=1\bigoplus\limits\_{v \in V} f(v) = 1 and concluded that such gg does not exist! But how to convince the jury that it is so?

Sam, the leader of this scam group, claims that such gg exists and that he knows exactly what it is. Pavel is going to ask him questions about this claimed gg until he finds a simple contradiction in Sam's answers.

Pavel can only ask questions in the form of boolean formulas with variables corresponding to the values of gg. Let us enumerate the edges and identify them with their numbers. Let us define a boolean formula:

  • gx\texttt{g}x, where x1,2,,Ex \in \\{1, 2, \ldots, |E|\\}, is a boolean formula. 
  • If FF is a boolean formula, then !(F)\texttt{!(}F\texttt{)} is a boolean formula.
  • If FF and GG are boolean formulas, then \texttt{(}F\texttt{)&(}G\texttt{)} and \texttt{(}F\texttt{)&(}G\texttt{)} are boolean formulas.

Sam answers 00 (false) or 11 (true) to each question. The types of simple contradictions that the jury recognizes are the following:

  1. The answer to FF is α\alpha, and the answer to !(F)\texttt{!(}F\texttt{)} is also α\alpha.
  2. The answer to FF is α\alpha, the answer to GG is β\beta, and the answer to \texttt{(}F\texttt{)&(}G\texttt{)} is not αβ\alpha \land \beta (here, \land is logical and).
  3. The answer to FF is α\alpha, the answer to GG is β\beta, and the answer to \texttt{(}F\texttt{)&(}G\texttt{)} is not αβ\alpha \lor \beta (here, \lor is logical or).  

Formally, Sam's claim that gg satisfies the parity condition for every vVv \in V which means that, for every vVv \in V, the equality _eI(v)g(e)=f(v)\bigoplus\limits\_{e \in I(v)} g(e) = f(v) holds, is interpreted as follows. For each vertex vVv \in V and each subset SI(v)S \subseteq I(v) such that its size Smod2f(v)|S| \bmod 2 \neq f(v), it is assumed that Sam has answered 11 to the formula _iS!(gi)_iI(v)Sgi. \bigvee\limits\_{i \in S} \texttt{!(g}i\texttt{)} \lor \bigvee\limits\_{i \in I(v) \setminus S} \texttt{g} i\text{.} We refer to these formulas as axioms. Pavel can ask them, and Sam will answer 11.

Here we assume that the whole big disjunction is written in right-associative form. For example, the formula xyzx \lor y \lor z is written as (x)|((y)|(z)). The variables in the axioms are ordered so that their numbers are increasing from left to right. So, for example, an axiom _i1,3!(gi)_i2gi\bigvee\limits\_{i \in \\{1, 3\\}} \texttt{!(g}i\texttt{)} \lor \bigvee\limits\_{i \in \\{2\\}} \texttt{g} i is written as (!(g1))|((g2)|(!(g3))).

Pavel would like to convince the jury as soon as possible, so he would like to ask at most 5050 questions.

Additionally, Pavel would like to ask formulas that are not too deep, so the jury wouldn't become confused. The depth d(F)d(F) of a formula FF is defined recursively:

  • d(gi)=1d(\texttt{g}i) = 1 for i1,,Ei \in \\{1, \ldots, |E|\\}.
  • d(!(F))=d(F)+1d(\texttt{!(}F\texttt{)}) = d(F) + 1.
  • d((F)|(G))=maxd(F),d(G)+1d(\texttt{(}F\texttt{)|(}G\texttt{)}) = \max \\{d(F), d(G)\\} + 1.
  • d(\texttt{(}F\texttt{)&(}G\texttt{)}) = \max \\{d(F), d(G)\\} + 1.

Every formula that Pavel asks must have depth at most 100100.

입력

The first line contains two integers nn and mm (1n1001 \le n \le 100, 1m1501 \le m \le 150): the number of vertices and the number of edges in GG respectively. The vertices are numbered from 11 to nn, and the edges are numbered from 11 to mm.

The second line contains nn integers f(1),f(2),,f(n)0,1f(1), f(2), \ldots, f(n) \in \\{0,1\\}. It is guaranteed that their sum is odd.

The next mm lines contain the description of the edges of GG. Each of these lines contains two distinct integers from the set 1,,n\\{1, \ldots, n\\}: the ends of the corresponding edge.

It is guaranteed that the given graph is connected and has maximum vertex degree at most 1010. Note that the graph may contain parallel edges.

힌트

In the example, the boolean formula "(!(g1))|(!(g2))" is an axiom.