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.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Stack;
import java.util.TreeSet;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        String[] tokens = in.readLine().trim().split(" ");
        int n = Integer.parseInt(tokens[0]);
        int m = Integer.parseInt(tokens[1]);

        int[] d = new int[n];

        tokens = in.readLine().trim().split(" ");
        for(int i = 0; i < n; i++) {
            d[i] = Integer.parseInt(tokens[i]);
        }

        int[][] edges = new int[m][2];

        for(int i = 0; i < m; i++) {
            tokens = in.readLine().trim().split(" ");
            edges[i][0] = Integer.parseInt(tokens[0]) - 1;
            edges[i][1] = Integer.parseInt(tokens[1]) - 1;
        }

        solve(n, m, d, edges);
    }

    public static void solve(int n, int m, int[] d, int[][] edges) {
        if(subsetSelectionPossible(d)) {
            List<Integer> subsetEdgeNumbers = getGoodSubsetOfEdges(n, m, d, edges);
            System.out.println(subsetEdgeNumbers.size());
            for(int edgeNumber : subsetEdgeNumbers) {
                System.out.println(edgeNumber + 1);
            }

        } else {
            System.out.println(-1);
        }
    }

    private static boolean subsetSelectionPossible(int[] d) {
        int sumOfDegrees = 0;
        int cntOfMinusOneDegrees = 0;
        for(int i = 0; i < d.length; i++) {
            if(d[i] != -1) {
                sumOfDegrees += d[i];
            } else {
                cntOfMinusOneDegrees++;
            }
        }

        if(sumOfDegrees % 2 == 0) {
            return true;
        }
        return (cntOfMinusOneDegrees >= 1);
    }

    private static List<Integer> getGoodSubsetOfEdges(int n, int m, int[] d, int[][] edges) {
        int[] newDegrees = getAValidSetOfDegreesForVetrices(d);
        int[][] adj = getAdjcencyList(n, m, edges);
        int[][] mstAdj = bfs(0, adj, n, newDegrees);
        List<Integer> subsetEdgeNumbers = new ArrayList<>();
        Map<Long, Integer> edgeNumberMap = new HashMap<>();

        for(int i = 0; i < m; i++) {
            int u = edges[i][0];
            int v = edges[i][1];

            edgeNumberMap.put(getIsEdgeIncludedKey(u, v), i);
            edgeNumberMap.put(getIsEdgeIncludedKey(v, u), i);
        }

        Set<Long> edgeIncluded = new HashSet<>();
        subsetEdgeNumbers = dfsOnMst(0, null, mstAdj, n, newDegrees, edgeIncluded, subsetEdgeNumbers,
                edgeNumberMap);

        Collections.sort(subsetEdgeNumbers);
        return subsetEdgeNumbers;
    }

    private static int[] getAValidSetOfDegreesForVetrices(int[] d) {
        int[] newDegrees = new int[d.length];

        int sumOfDegrees = 0;
        int posOfFirstMinusOneDegree = -1;
        for(int i = 0; i < d.length; i++) {
            if(d[i] != -1) {
                newDegrees[i] = d[i];
                sumOfDegrees += d[i];
            } else {
                posOfFirstMinusOneDegree = i;
            }
        }

        if(sumOfDegrees % 2 == 1) {
            newDegrees[posOfFirstMinusOneDegree] = 1;
        }
        return newDegrees;
    }

    private static int[][] getAdjcencyList(int n, int m, int[][] edges) {
        int[][] adj = new int[n][];
        int[] adjSize = new int[n];

        Set<Long> isEdgeIncluded = new HashSet<>();

        for(int i = 0; i < m; i++) {
            int u = edges[i][0];
            int v = edges[i][1];

            if(isEdgeIncluded.contains(getIsEdgeIncludedKey(u, v))) {
                continue;
            }

            adjSize[u]++;
            adjSize[v]++;

            isEdgeIncluded.add(getIsEdgeIncludedKey(u, v));
            isEdgeIncluded.add(getIsEdgeIncludedKey(v, u));
        }

        for(int i = 0; i < n; i++) {
            adj[i] = new int[adjSize[i]];
            adjSize[i] = 0;
        }

        isEdgeIncluded.clear();

        for(int i = 0; i < m; i++) {
            int u = edges[i][0];
            int v = edges[i][1];

            if(isEdgeIncluded.contains(getIsEdgeIncludedKey(u, v))) {
                continue;
            }

            adj[u][adjSize[u]++] = v;
            adj[v][adjSize[v]++] = u;

            isEdgeIncluded.add(getIsEdgeIncludedKey(u, v));
            isEdgeIncluded.add(getIsEdgeIncludedKey(v, u));
        }

        return adj;
    }

    private static int[][] bfs(int root, int[][] adj, int n, int[] d) {
        Stack<Integer> stack = new Stack<>();
        boolean[] visited = new boolean[n];
        int[][] mstAdj = new int[n][];
        int[] mstAdjSize = new int[n];

        for(int i=0; i<n; i++) {
            mstAdj[i] = new int[adj[i].length];
            Arrays.fill(mstAdj[i], -1);
        }

        stack.push(root);
        visited[root] = true;

        while (!stack.isEmpty()) {
            int u = stack.pop();
            for(int i = 0; i < adj[u].length; i++) {
                int v = adj[u][i];
                if(!visited[v]) {
                    mstAdj[u][mstAdjSize[u]++] = v;
                    mstAdj[v][mstAdjSize[v]++] = u;

                    stack.add(v);
                    visited[v] = true;
                }
            }
        }

        return mstAdj;
    }

    private static List<Integer> dfsOnMst(int u, Integer parent, int[][] adj, int n, int[] newDegrees, Set<Long> edgeIncluded,
                                 List<Integer> subsetEdgeNumbers, Map<Long, Integer> edgeNumberMap) {
        int subtreeActualDegree = 0;
        for(int v : adj[u]) {
            if(v == -1) {
                break;
            }

            if(parent != null && parent == v) {
                continue;
            }
            dfsOnMst(v, u, adj, n, newDegrees, edgeIncluded, subsetEdgeNumbers, edgeNumberMap);
            if(edgeIncluded.contains(getIsEdgeIncludedKey(u, v))) {
                subtreeActualDegree++;
            }
        }
        int subtreeExpectedDegree = newDegrees[u];
        if(subtreeActualDegree != subtreeExpectedDegree) {
            // Consider the edge to parent
            if(parent != null) {
                edgeIncluded.add(getIsEdgeIncludedKey(u, parent));
                edgeIncluded.add(getIsEdgeIncludedKey(parent, u));

                int edgeNumber = edgeNumberMap.get(getIsEdgeIncludedKey(u, parent));
                subsetEdgeNumbers.add(edgeNumber);
            }

        } else {
            // Do not consider the edge to parent
        }

        return subsetEdgeNumbers;
    }

    private static long getIsEdgeIncludedKey(int u, int v) {
        long OFFSET = (long) Integer.MAX_VALUE;
        return (u * OFFSET) + v;
    }
}
