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.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.io.BufferedInputStream;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		BufferedInputStream in = new BufferedInputStream(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskD {
		ArrayList<Integer> ret = new ArrayList<>();
		int[] d;
		int n;
		int[][][] gw;
		boolean[] visited;

		int dfs(int v) {
			visited[v] = true;
			int cur = d[v];
			for (int[] ed : gw[v]) {
				int u = ed[0];
				if (!visited[u]) {
					if (dfs(u) != 0) {
						ret.add(ed[1]);
						cur = 1 - cur;
					}
				}
			}
			if (d[v] == -1)
				return 0;

			return cur;
		}

		public void solve(int testNumber, BufferedInputStream _in, PrintWriter out) {

			InputReader in = new InputReader(_in);
			long startTime = System.currentTimeMillis();
			n = in.nextInt();
			int m = in.nextInt();
			d = new int[n];
			int st = -1;
			int cnt = 0;
			for (int i = 0; i < n; ++i) {
				d[i] = in.nextInt();
				if (d[i] != -1) cnt += d[i];
				else {
					st = i;
				}

			}

			if (cnt % 2 == 1 && st == -1) {
				out.println(-1);
				return;
			}
			if (st == -1) st = 0;

			int[] from = new int[m];
			int[] to = new int[m];
			int[] w = new int[m];
			for (int i = 0; i < m; ++i) {
				from[i] = in.nextInt() - 1;
				to[i] = in.nextInt() - 1;
				w[i] = i;
			}

			gw = Graphs.packWU(n, from, to, w);
			visited = new boolean[n];
			dfs(st);

			out.println(ret.size());
			for (int x : ret) {
				out.println(x + 1);
			}

			in.close();
			System.err.println("Time: " + (System.currentTimeMillis() - startTime) + " miliseconds");
		}

	}

	static class InputReader {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public static boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public void close() {

		}

	}

	static class Graphs {
		public static int[][][] packWU(int n, int[] from, int[] to, int[] w) {
			int[][][] g = new int[n][][];
			int[] p = new int[n];
			for (int f : from)
				p[f]++;
			for (int t : to)
				p[t]++;
			for (int i = 0; i < n; i++)
				g[i] = new int[p[i]][2];
			for (int i = 0; i < from.length; i++) {
				--p[from[i]];
				g[from[i]][p[from[i]]][0] = to[i];
				g[from[i]][p[from[i]]][1] = w[i];
				--p[to[i]];
				g[to[i]][p[to[i]]][0] = from[i];
				g[to[i]][p[to[i]]][1] = w[i];
			}
			return g;
		}

	}
}

