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

# https://codeforces.com/problemset/problem/840/B

n, m  =  map(int, input().split())
d     =  list(map(int, input().split()))

g={}
def push(g, u, v, i):
    if u not in g:
        g[u]=[]
    if v not in g:
        g[v]=[]
    g[u].append([v, i+1])
    g[v].append([u, i+1])
    
for i in range(m):
    u, v = map(int, input().split())
    push(g, u-1, v-1, i)

def solve(d, g):
    pos = []
    S   = 0
    
    for i, x in enumerate(d):
        if x==-1:
            pos.append(i)
        else:
            S+=x
            
    if S%2==1: 
        if len(pos)==0:
            return False, None
        
        d[pos[0]]=1
        for x in pos[1:]:
            d[x]=0
            
    root=0
    S    = [root]
    edge = [-1]
    used = [0]*n
    
    used[root]=1
    p=[None]*n
    i=0
    
    while i<len(S):
        u=S[i]
        if u in g:
            for v, edge_ in g[u]:
                if v==p[u] or used[v]==1:
                    continue
                p[v]=u    
                used[v]=1
                S.append(v)
                edge.append(edge_)
        i+=1
        
    ans=[]    
    for v, edge_ in zip(S[1:][::-1], edge[1:][::-1]):
        if d[v]==1:
            u = p[v]
            d[u]=1-d[u] 
            ans.append(str(edge_))
    return True, ans       

flg, ans =solve(d, g)

if flg==False:
    print(-1)
else:
    print(len(ans))
    print('\n'.join(ans))