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.util.ArrayList;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;
import java.awt.PageAttributes.OriginType;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskC {
		class B implements Comparable<B> {
			int orginalPosition, value;

			public B(int orginalPosition, int value) {
				this.orginalPosition = orginalPosition;
				this.value = value;
			}

			@Override
			public int compareTo(B o) {
				// TODO Auto-generated method stub
				return Integer.compare(o.value, value);
			}

		}

		class Edge {
			boolean isUsed = false;
			int index;
			Node n1;
			Node n2;

			public Edge(Node n1, Node n2, int index) {
				this.n1 = n1;
				this.n2 = n2;
				this.index = index;
			}

			Node getNext(Node current) {
				return (n1 == current) ? n2 : n1;
			}
		}

		class Node {
			int neededDegree;
			int degree = 0;
			ArrayList<Edge> edges = new ArrayList<>();
			// boolean marked;
		}

		static Random r = new Random();

		boolean set_1NodeTo1AndOthersTo0(Node[] nodes) {
			boolean success = false;
			for (Node n : nodes) {
				if (n.neededDegree == -1) {
					n.neededDegree = 1;
					success = true;
					break;
				}
			}
			return success;
		}

		void setAll_1To0(Node[] nodes) {
			for (Node n : nodes) {
				if (n.neededDegree == -1) {
					n.neededDegree = 0;
				}
			}
		}

		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			int m = in.nextInt();
			Node[] nodes = new Node[n];
			int numberOf1 = 0;
			for (int i = 0; i < n; i++) {
				nodes[i] = new Node();
				int d;
				nodes[i].neededDegree = (d = in.nextInt());
				if (d == 1) {
					numberOf1++;
				}
			}
			if (numberOf1 % 2 == 1) {
				if (!set_1NodeTo1AndOthersTo0(nodes)) {
					out.println("-1");
					return;
				}
			}
			setAll_1To0(nodes);
			Edge[] edges = new Edge[m];

			for (int i = 0; i < m; i++) {
				int u = in.nextInt() - 1;
				int v = in.nextInt() - 1;
				Edge e = new Edge(nodes[u], nodes[v], i + 1);
				edges[i] = e;
				nodes[u].edges.add(e);
				nodes[v].edges.add(e);
			}

			ArrayList<Node> notGoodNodes = new ArrayList<>();
			for (Node node : nodes) {
				if (node.degree % 2 != node.neededDegree) {
					notGoodNodes.add(node);
				}
			}

			while (!notGoodNodes.isEmpty()) {
				int nextIndex = r.nextInt(notGoodNodes.size());
				Node node = notGoodNodes.get(nextIndex);
				notGoodNodes.remove(nextIndex);
				Edge edge = node.edges.get(r.nextInt(node.edges.size()));
				if(edge.isUsed){
					edge.isUsed = false;
					edge.n1.degree--;
					edge.n2.degree--;
				}else{
					edge.isUsed = true;
					edge.n1.degree++;
					edge.n2.degree++;
				}
				node = edge.getNext(node);
				if (node.degree % 2 != node.neededDegree) {
					notGoodNodes.add(node);
				}
			}
			int k = 0;
			for (Edge e : edges) {
				if (e.isUsed) {
					k++;
				}
			}
			out.println(k);
			for (Edge e : edges) {
				if (e.isUsed) {
					out.println(e.index);
				}
			}
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

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

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

		public double nextFloat() {
			return Double.parseDouble(next());
		}

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

	}
}
