You are given an undirected graph with vertices numbered and edges. Vertex initially contains coins.
In one operation, choose adjacent vertices and such that contains a positive even number of coins and contains an odd number of coins. Move one coin from to . Both conditions are checked before the transfer.
You are also given an array . Determine whether, after zero or more operations, every vertex can contain exactly coins.
Operations are performed one after another. The same edge may be used more than once, in either direction when the conditions allow it.
Output Yes if it is possible, and No otherwise. The case of the letters is ignored.
Move one coin from vertex to vertex .
Vertex is empty and cannot take part in any operation, so no transfer can take place.
The only possible first operation produces . From there, the only operation returns to .
Transfer one coin from vertex to vertex , then from vertex to vertex .