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

// actually solves 840b
// there was a mix-up in the naming of these sets

public class cf840d implements Runnable{
	static class Node{
		int dex, label;
		ArrayList<Edge> nexts = new ArrayList<>(4);
		ArrayList<Edge> children = new ArrayList<>(4);
		Node(int dex, int label){
			this.dex = dex;
			this.label = label;
		}
	}
	static int amtEdges = 0;
	static class Edge{
		int dex;
		boolean chosen = false;
		Node a, b;
		Edge(Node a, Node b){
			dex = amtEdges++;
			this.a = a;
			this.b = b;
			a.nexts.add(this);
			b.nexts.add(this);
		}
		Node other(Node i){
			return i == a? b: a;
		}
	}
	public static void main(String[] args) {
		new Thread(null, new cf840d(), "", 1<<28).start();
	}
	static void dfs(boolean[] visited, Node node){
		visited[node.dex] = true;
		for(Edge e : node.nexts){
			Node v = e.other(node);
			if(visited[v.dex]) continue;
			visited[v.dex] = true;
			node.children.add(e);
			dfs(visited, v);
		}
	}
	static boolean toggleOn = false;
	static void dfs2(Node node){
		if(node.label == 1) toggleOn = !toggleOn;
		for(Edge e : node.children){
			// fortracking the edge
			if(toggleOn) e.chosen = !e.chosen;
			// recursive call
			dfs2(e.other(node));
			// backtracking the edge
			if(toggleOn) e.chosen = !e.chosen;
		}
	}
	public void run() {
		DamnScanner in = new DamnScanner();
		
		int N = in.nextInt();
		int M = in.nextInt();
		
		Node[] nodes = new Node[N];
		int amtOnes = 0;
		for(int n=0;n<N;n++){
			int label = in.nextInt();
			if(label == 1) amtOnes++;
			nodes[n] = new Node(n, label);
		}
		
		if(amtOnes % 2 == 1){
			// gotta change a -1 to a 1
			int n;
			for(n=0;n<N;n++){
				if(nodes[n].label == -1){
					nodes[n].label = 1;
					break;
				}
			}
			if(n == N){
				System.out.println("-1");
				return;
			}
		}
		
		ArrayList<Edge> edges = new ArrayList<>(M);
		for(int m=0;m<M;m++){
			edges.add(new Edge(nodes[in.nextInt()-1], nodes[in.nextInt()-1]));
		}
		
		// construct the tree
		dfs(new boolean[N], nodes[0]);
		
		// build the paths
		dfs2(nodes[0]);
		
		StringBuilder sb = new StringBuilder();
		int numStuff = 0;
		for(Edge e : edges){
			if(e.chosen){
				numStuff++;
				sb.append((e.dex+1)+" ");
			}
		}
		
		System.out.println(numStuff);
		if(numStuff > 0) System.out.println(sb.toString().trim());
	}
	static class DamnScanner{ // i'm mad that Scanner is too slow
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] line = new String[]{""};
		int count = 1;
		void ensure(){
			if(count >= line.length){
				count = 0;
				try{ line = br.readLine().split(" "); }catch(IOException ioe){}
			}
		}
		int nextInt(){
			ensure();
			return Integer.parseInt(line[count++]);
		}
	}
}
