3 2
1 0 1
1 2
2 3
 10 10
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1
6 7
8 3
6 4
4 2
9 2
5 10
9 8
10 7
5 1
6 2

2
1
2
 0

P = [int(i) for i in input().split()]
V = [int(i) for i in input().split()]
E = []
G = {
	   i: [] for i in range(1, P[0]+1)
}

for i in range(P[1]):
	X = [int(i) for i in input().split()]
	G[X[0]].append(X[1])
	G[X[1]].append(X[0])
	E.append(tuple(X))
if not E:
	print(-1)
else:
	NEG = []
	DEG = []
	L = len(E)
	for i in range(L):
		if V[E[i][0]-1] == -1 and V[E[i][1]-1] == -1:
			NEG.append(i)
		E1 = G[E[i][0]]
		E2 = G[E[i][1]]
		if len(E1)%2 == V[E[i][0]-1] and len(E2)%2 == V[E[i][1]-1]:
			DEG.append((i, E[i]))
	OUT = set(NEG + DEG)
	print(len(OUT))
	for i in OUT:
		print(i[0] + 1)
