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

import sys

N = 300000
pnt = [0 for i in range(0, N)]
nxt = [-1 for i in range(0, N)]
head = [-1 for i in range(0, N)]
edge = [0 for i in range(0, N)]
vis = [False for i in range(0, N)]
select = [False for i in range(0, N)]
d = []
cnt = 0

class P:
	def __init__(self, u, id):
		self.u = u
		self.id = id

fa = [P(0, 0) for i in range(0, N)]

def getList(i) :
	l = []
	while i >= 0:
		l.append(i)
		i = nxt[i]
	return l

def addedge(u, v, x) :
	global cnt
	pnt[cnt] = v; nxt[cnt] = head[u]; head[u] = cnt; edge[cnt] = x; cnt += 1;
	pnt[cnt] = u; nxt[cnt] = head[v]; head[v] = cnt; edge[cnt] = x; cnt += 1;

def dfs(u, f) :
	for i in getList(head[u]):
		v = pnt[i]
		if v == f or vis[v]:
			continue
		id = edge[i]
		vis[v] = True
		fa[v] = P(u, id)
		dfs(v, u)
		if d[v] == 1:
			select[id] ^= 1
			d[v] = 0
			if d[u] != -1:
				d[u] ^= 1
		


if __name__ == "__main__" :
	n, m = map(int, raw_input().split())
	cur = list(map(int, raw_input().split()))
	d = [0] + cur
	node = -1
	for i in range(0, len(d)):
		if d[i] == -1:
			node = i
			break
		
	for i in range(0, m):
		u, v = map(int, raw_input().split())
		addedge(u, v, i)
	
	dfs(1, -1)
	if d[0] == 1 :
		if node == -1:
			print '-1'
			sys.exit(0)
		while node != 0:
			select[fa[node].id] ^= 1
			node = fa[node].u
	ans = 0
	for i in range(0, m):
		if select[i]:
			ans += 1
	print ans
	for i in range(0, m):
		if select[i]:
			print i + 1,

	

