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

//package ;
import java.awt.Point;
import java.io.*;
import java.util.*;

public class CF {
	static int n,m;
	static ArrayList<Edge>adjList[];
	static int[] d,a;
	static HashMap<Point, Integer>hm;
	static Point[]p;
	static class Edge
	{
		int node;boolean used;
		public Edge(int u) {
			// TODO Auto-generated constructor stub
			node=u;used=false;
		}
	}
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter pw = new PrintWriter(System.out);
		n=sc.nextInt();m=sc.nextInt();
		adjList=new ArrayList[n];
		p=new Point[m];
		hm=new HashMap<>();
		d=new int[n];
		a=new int[n];
		for(int i=0;i<n;i++)
		{
			adjList[i]=new ArrayList<>();
			d[i]=sc.nextInt();
		}
		for(int i=0;i<m;i+=1)
		{
			int u=sc.nextInt()-1,v=sc.nextInt()-1;
			adjList[u].add(new Edge(v));
			adjList[v].add(new Edge(u));
			a[u]++;
			a[v]++;
			a[u]%=2;
			a[v]%=2;
			p[i]=new Point(u, v);
		}
		for(int i=0;i<n;i++)
		{
			if(a[i]!=d[i] && d[i]!=-1)
			{
				vis=new boolean[n];
				if(dfs(i))
				{	
					a[i]=d[i];
				}
				else
				{
					System.out.println(-1);
					return;
				}
			}
		}
		pw.println(m-hm.size());
//		System.err.println(hm);
		for(int i=0;i<m;i++)
		{
			Point t=new Point(p[i].y,p[i].x);
			if(hm.containsKey(t))
			{
				int x=hm.get(t);
				x--;
				if(x>0)
					hm.put(t, x);
				else
					hm.remove(t);
			}
			else if(hm.containsKey(p[i]))
			{
				int x=hm.get(p[i]);
				x--;
				if(x>0)
					hm.put(p[i], x);
				else
					hm.remove(p[i]);
			}
			else
				pw.println(i+1);
		}
		pw.close();
	}
	static boolean vis[];
	static Stack<Integer>st;
	static void dfs_stack(int u)
	{
		vis[u]=true;
		
		for(Edge e:adjList[u])
		{
			int v=e.node;
			if(!vis[v])
				dfs(v);
		}
	}
	static boolean dfs(int u)
	{
		vis[u]=true;
		for(Edge e:adjList[u])
		{
			int v=e.node;
			if(vis[v])continue;
			if(a[v]!=d[v] || d[v]==-1)
			{
				boolean f=dfs(v);
				a[v]=d[v];
				if(f)
					continue;
				e.used=!e.used;
				Point p=new Point(u,v);
				if(e.used)
					hm.put(p, hm.getOrDefault(p, 0)+1);
				else
				{	
					int x=hm.get(p);
					x--;
					if(x>0)
						hm.put(p, x);
					else
						hm.remove(p);
				}
				return true;
			}
			else
			{
				boolean f=dfs(v);
				if(f)
				{
					a[v]=d[v];
					Point p=new Point(u,v);
					e.used=!e.used;
					if(e.used)
						hm.put(p, hm.getOrDefault(p, 0)+1);
					else
					{
						int x=hm.get(p);
						x--;
						if(x>0)
							hm.put(p, x);
						else
							hm.remove(p);
					}
					return true;
				}
			}
		}
		return false;
	}
	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		}

		int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

		boolean hasnext() throws IOException {
			return br.ready();
		}

	}
}
//3 3
//0 -1 1
//1 2
//1 3
//1 3

//5 6
//0 0 1 0 1
//1 2
//2 3
//2 3
//3 4
//1 5
//1 5