406471: GYM102419 D Xor the graph

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

D. Xor the graphtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

You are given an undirected graph with $$$n$$$ nodes and $$$m$$$ edges.

The graph doesn't contain self-loops but it may contain multiple edges.

There is a number $$$a_i$$$ attached to the $$$i_{th}$$$ $$$(1 \leq i \leq n)$$$ node.

You can do the following operation once: Choose a set of nodes and a value $$$x$$$ $$$(0 \leq x < 2 ^ {20})$$$ and change all the values of the nodes in the set from $$$a_i$$$ into $$$a_i \bigoplus x$$$.

You should choose any set and any value $$$x$$$ so that for each edge the values of the nodes connected with that edge are different.

Is it possible?

Input

The first line of input contains two integers $$$n$$$ and $$$m$$$, which are the number of nodes and the number of edges $$$(1 \leq n , m \leq 3 \times 10 ^ {5})$$$.

The second line contains $$$n$$$ integers, the $$$i^{th}$$$ one is $$$a_i$$$ which is the value attached to the $$$i^{th}$$$ node $$$(0 \leq a_i < 2 ^ {20})$$$.

The next $$$m$$$ lines will contain two integers for each $$$u$$$ and $$$v$$$, $$$(1 \leq u , v \leq n)$$$ $$$(u \neq v)$$$, which means that there is an edge between nodes $$$u$$$ and $$$v$$$.

it is guaranteed that the given graph doesn't contain self-loops but it may contain multiple edges.

Output

If there is no way to choose a set and a value $$$x$$$, print $$$-1$$$.

Otherwise print two integers $$$k$$$ and $$$x$$$ on the first line, which is the size of the chosen set and the chosen value, $$$(1 \leq k \leq n)$$$ $$$(0 \leq x < 2 ^ {20})$$$.

In the second line print $$$k$$$ integers, which describes the chosen nodes in the set.

Make sure that no node appears more than one time in the set.

ExamplesInput
3 3
1 1 1
1 2
2 3
1 3
Output
-1
Input
3 3
1 1 2
1 2
2 3
1 3
Output
1 1
2
Input
5 4
1 2 3 4 5
1 2
1 3
1 4
4 5
Output
0 1

Source/Category

加入题单

算法标签: