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

sys.setrecursionlimit(500000)

n, m = map(int, sys.stdin.readline().split())
d = list(map(int, sys.stdin.readline().split()))
gph = [[] for _ in range(n)]

for _ in range(m):
    u, v = map(int, sys.stdin.readline().split())
    u -= 1
    v -= 1
    gph[u].append((v, _))
    gph[v].append((u, _))
    
t = -1
if d.count(1) % 2 == 1:
    if 0 not in d:
        print(-1)
        exit(0)
    t = d.index(0)

ans = [False] * m
vis = [False] * n
def go (u):
    vis[u] = True
    ret = (d[u] == 1) or (u == t)
    for v, i in gph[u]:
        if not vis[v] and go(v):
            ret = not ret
            ans[i] = True
    return ret
    
go(0)
print(ans.count(True))
print("\n".join([str(i+1) for i in range(m) if ans[i]]))