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

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define int long long
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t,vis[li],visit[li],deg[li];
int cev;
string s;
vector<PII> v[li];
vector<int> vv;

inline void dfs(int node){
	if(vis[node]==1)return ;
	vis[node]=1;
	for(int i=0;i<(int)v[node].size();i++){
		int go=v[node][i].fi;
		int edge=v[node][i].se;
		if(a[go]%2==1){vv.pb(edge);a[node]=!a[node];}
		dfs(go);
	}
}

main(void){
	scanf("%lld %lld",&n,&m);
	FOR{
		scanf("%lld",&a[i]);
		if(a[i]>0)cev+=a[i];
	}
	//~ cout<<cev<<endl;
	FOR{
		if(cev%2==1 && a[i]==-1){cev--;a[i]=1;}
		else if(a[i]==-1) a[i]=0;
	}
	//~ cout<<cev<<endl;
	if(cev%2==1){printf("-1\n");return 0;}
	for(int i=1;i<=m;i++){
		int x,y;
		scanf("%lld %lld",&x,&y);
		v[x].pb(mp(y,i));
		v[y].pb(mp(x,i));
		
	}
	dfs(1);
	printf("%lld\n",(int)vv.size());
	for(int i=0;i<(int)vv.size();i++)printf("%lld\n",vv[i]);
	return 0;
}
