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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;


public class D {
	static ArrayList<Integer>[] graph;
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken());
		int m = Integer.parseInt(st.nextToken());
		int[] ver = new int[n];
		int[] deg = new int[n];
		int[][] edge = new int[n][n];
		graph = new ArrayList[n];
		st = new StringTokenizer(br.readLine());
		for (int i = 0; i < n; i++) {
			ver[i] = Integer.parseInt(st.nextToken());
		}
		
		for (int i = 0; i < n; i++) {
			graph[i] = new ArrayList<Integer>();
		}
		for (int i = 0; i < m; i++) {
			st = new StringTokenizer(br.readLine());
			int u = Integer.parseInt(st.nextToken()) - 1;
			int v = Integer.parseInt(st.nextToken()) - 1;
			edge[u][v] = edge[v][u] = i;
			deg[u]++;
			deg[v]++;
			graph[u].add(v);
			graph[v].add(u);
		}
		
		ArrayList<Integer> sol = new ArrayList<Integer>();
		
		for (int i = 0; i < ver.length; i++) {
			if(ver[i] != -1 && ver[i] != deg[i]%2)
			{
				if(deg[i] == 0)
				{
					System.out.println(-1);
					return;
				}
				for(int v : graph[i])
				{
					if(ver[v] != deg[v]%2)
					{
						deg[i]--;
						deg[v]--;
						sol.add(edge[i][v] + 1);
						break;
					}
				}
			}
		}
		if(sol.size() == 0)
		{
			for (int i = 0; i < ver.length; i++) 
			{
				for(int v : graph[i])
				{
					if((ver[i] == -1 && ver[v] == -1) || (ver[i] == -1 && ver[v] != deg[v]%2) || ver[i] == deg[i]%2 && ver[v] == deg[v]%2)
					{
						sol.add(edge[i][v] + 1);
						i = ver.length;
						break;
					}
				}
			}
		}
		
		StringBuilder sb = new StringBuilder();
		sb.append(sol.size()).append("\n");
		for(int i : sol)
		{
			sb.append(i).append("\n");
		}
		System.out.println(sb);
	}
}
