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 java.util.*;
import java.io.*;

public class _0840_B_LehaAndAnotherGameAboutGraph {
	
	public static class Edge{
		int to, id;
		public Edge(int to, int id) {
			this.to = to; this.id = id;
		}
	}

	public static void main(String[] args) throws IOException {
		int N = readInt(), M = readInt(); ArrayList<Edge> graph[] = new ArrayList[N+1];
		for(int i = 1; i<=N; i++) graph[i] = new ArrayList<>();
		int dgr[] = new int[N+1], sum = 0; for(int i = 1; i<=N; i++) {dgr[i] = readInt(); sum += dgr[i] == 1 ? 1 : 0;}
		sum%=2; for(int i = 1; i<=N; i++) if(dgr[i] == -1) {dgr[i] = sum%2; sum += dgr[i];} sum%=2;
		if(sum%2 == 1) {println(-1); exit();} boolean vis[] = new boolean[N+1]; int par[] = new int[N+1], id[] = new int[N+1];
		for(int i = 1; i<=M; i++) {int a = readInt(), b = readInt(); graph[a].add(new Edge(b, i)); graph[b].add(new Edge(a, i));}
		Stack<Integer> stk1 = new Stack<>(), stk2 = new Stack<>(); stk1.add(1); vis[1] = true; while(!stk1.isEmpty()) {
			int n = stk1.pop(); stk2.add(n); for(Edge e : graph[n]) if(!vis[e.to]) {
				vis[e.to] = true; stk1.add(e.to); par[e.to] = n; id[e.to] = e.id;
			} 
		} while(!stk2.isEmpty()) {
			int n = stk2.pop(); if(dgr[n] == 1) {dgr[n]--; dgr[par[n]] = (dgr[par[n]]+1)%2; stk1.add(id[n]);}
		}
		println(stk1.size()); while(!stk1.isEmpty()) print(stk1.pop() + " "); exit();
	}

	final private static int BUFFER_SIZE = 1 << 16;
	private static DataInputStream din = new DataInputStream(System.in);
	private static byte[] buffer = new byte[BUFFER_SIZE];
	private static int bufferPointer = 0, bytesRead = 0;
	static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	public static String readLine() throws IOException {
		byte[] buf = new byte[64]; // line length
		int cnt = 0, c;
		while ((c = Read()) != -1) {
			if (c == '\n')
				break;
			buf[cnt++] = (byte) c;
		}
		return new String(buf, 0, cnt);
	}

	public static String read() throws IOException {
		byte[] ret = new byte[1024];
		int idx = 0;
		byte c = Read();
		while (c <= ' ') {
			c = Read();
		}
		do {
			ret[idx++] = c;
			c = Read();
		} while (c != -1 && c != ' ' && c != '\n' && c != '\r');
		return new String(ret, 0, idx);
	}

	public static int readInt() throws IOException {
		int ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (neg)
			return -ret;
		return ret;
	}

	public static long readLong() throws IOException {
		long ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');
		if (neg)
			return -ret;
		return ret;
	}

	public static double readDouble() throws IOException {
		double ret = 0, div = 1;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();

		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (c == '.') {
			while ((c = Read()) >= '0' && c <= '9') {
				ret += (c - '0') / (div *= 10);
			}
		}

		if (neg)
			return -ret;
		return ret;
	}

	private static void fillBuffer() throws IOException {
		bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
		if (bytesRead == -1)
			buffer[0] = -1;
	}

	private static byte Read() throws IOException {
		if (bufferPointer == bytesRead)
			fillBuffer();
		return buffer[bufferPointer++];
	}

	static void print(Object o) {
		pr.print(o);
	}

	static void println(Object o) {
		pr.println(o);
	}

	static void flush() {
		pr.flush();
	}

	static void println() {
		pr.println();
	}

	static void exit() throws IOException {
		din.close();
		pr.close();
		System.exit(0);
	}
}
