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
import operator
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i in range(n):
    if a[i]==-1 or a[i]==1:
        b.append(1)
    else:
        b.append(0)
ans=[0]
for i in range(m):
    k1,k2=map(int,input().split())
    if b[k1-1]==1 and b[k2-1]==1:
        ans.append(i+1)
if n==1:
    print(-1)
else:
    if len(ans)==1:
        print(len(ans)-1)
    else:
        print(len(ans)-1)
        print(" ".join(str(i) for i in ans[1:]))
