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

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
//#define int                 long long
#define ll              	long long
#define ld                  long double
#define rep(i,n)            for(int i=0;i<n;i++)
#define hell                1000000007
#define inf                 (ll)1e15
#define vi                  vector<int>
#define vii                 vector< vi >
#define pb                  push_back
#define mp                  make_pair
#define fi                  first
#define se                  second
#define pii                 pair<int,int>
#define all(c)              c.begin(),c.end()
#define sz(c)               (int)c.size()
#define hash1               105727LL
#define hash2               hell
#define eps                 1e-10
#define pi                  3.141592653589793238462643383279502884197
typedef tree<pair<int,int>,null_type,less<pair<int,int> >,
				rb_tree_tag,tree_order_statistics_node_update> statisticsTree;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
ll power(ll x, ll y,ll p)
{
	ll res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
			res=((res%p)*(x%p))%p;
		y=y>>1;
		x=((x%p)*(x%p))%p;
	}
	return res;
}
ll raichu(ll x,ll y)
{
	ll res=1;
	while(y>0)
	{
		if(y&1)
			res=((res)*(x));
		y=y>>1;
		x=((x)*(x));
	}
	return res;
}
bool isprime(ll n)
{
	if(n<2) return false;
	else if(n==2) return true;
	else if(n%2==0) return false;
	else
	{
		ll z=sqrt(n);
		rep(i,z-1) if(n%(i+2)==0) return false;
		return true;
	}
}
int32_t main()
{
	//freopen("B-large.in","r",stdin);
	//freopen("out4.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1,Tests;
	//cin>>tests;
	Tests=tests;
	while(tests--)
	{
		int n,m;
		cin>>n>>m;
		vi v(n);
		rep(i,n) cin>>v[i];
		vector<pair<int,int> > V;
		rep(i,n) V.pb(mp(v[i],i));
		sort(all(V));
		reverse(all(V));
		vector<vector<pair<int,pair<int,int> > > > g(n);
		rep(i,m)
		{
			int x,y;
			cin>>x>>y;
			--x;
			--y;
			g[x].pb(mp(v[y],mp(i,y)));
			g[y].pb(mp(v[x],mp(i,x)));
		}
		rep(i,n)
		{
			sort(all(g[i]));
			reverse(all(g[i]));
		}
		vector<int> chk(m,0);
		vector<int> deg(n,0);
		rep(i,n)
		{
			int x=V[i].se;
			int z1=V[i].fi;
			for(auto j:g[x])
			{
				int y=j.se.se;
				int z2=j.fi;
				int e=j.se.fi;
				if(chk[e]==0)
				{
					if(z1==-1)
					{
						if(z2==-1)
						{
							chk[e]=1;
							deg[x]++;
							deg[y]++;
						}
						else if(z2==0)
						{
							if(deg[y]%2==1)
							{
								chk[e]=1;
								deg[x]++;
								deg[y]++;
							}
						}
						else if(z2==1)
						{
							if(deg[y]%2==0)
							{
								chk[e]=1;
								deg[x]++;
								deg[y]++;
							}
						}
					}
					else if(z1==0)
					{
						if(deg[x]%2==1)
						{
							chk[e]=1;
							deg[x]++;
							deg[y]++;
						}
					}
					else if(z1==1)
					{
						if(deg[x]%2==0)
						{
							chk[e]=1;
							deg[x]++;
							deg[y]++;
						}
					}
				}
			}
		}
		rep(i,n)
		{
			if(v[i]!=-1)
			{
				if((deg[i]%2)!=v[i])
				{
					cout<<-1;
					return 0;
				}
			}
		}
		int ans=0;
		rep(i,n) ans+=chk[i];
		cout<<ans<<endl;
		rep(i,n)
		{
			if(chk[i]==1)
			{
				cout<<i+1<<endl;
			}
		}
	}
	return 0;
}