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.ArrayList;
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.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeSet;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();
        int m = in.nextInt();

        int[] d = new int[n];

        for(int i = 0; i < n; i++) {
            d[i] = in.nextInt();
        }

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

        for(int i = 0; i < m; i++) {
            edges[i][0] = in.nextInt() - 1;
            edges[i][1] = in.nextInt() - 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);
        TreeSet<Node> leafNodesOfMST = 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);
        }

        while(!leafNodesOfMST.isEmpty()) {
            Node uNode = leafNodesOfMST.pollFirst();
            Node parentNode = uNode.getParent();

            if(parentNode == null) {
                continue;
            }

            if((uNode.getActualDegree() % 2) != uNode.getExpectedDegree()) {
                // Consider the edge to parent
                int u = uNode.getId();
                int v = parentNode.getId();
                int edgeNumber = edgeNumberMap.get(getIsEdgeIncludedKey(u, v));
                subsetEdgeNumbers.add(edgeNumber);
            } else {
                // Do not consider the edge to parent
                parentNode.setActualDegree(parentNode.getActualDegree() - 1);
            }

            leafNodesOfMST.add(parentNode);
        }

        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 long getIsEdgeIncludedKey(int u, int v) {
        long OFFSET = (long) Integer.MAX_VALUE;
        return (u * OFFSET) + v;
    }

    private static TreeSet<Node> bfs(int root, int[][] adj, int n, int[] d) {
        Stack<Node> stack = new Stack<>();
        boolean[] visited = new boolean[n];
        TreeSet<Node> leafNodes = new TreeSet<>(new Comparator<Node>() {
            @Override
            public int compare(Node o1, Node o2) {
                return (o2.getDepth() - o1.getDepth());
            }
        });

        Node rootNode = new Node(root, d[root], 0);
        stack.push(rootNode);

        while (!stack.isEmpty()) {
            Node uNode = stack.pop();
            int u = uNode.getId();
            int cntOfSubtreeConnectedEdges = 0;

            visited[u] = true;

            for(int i = 0; i < adj[u].length; i++) {
                int v = adj[u][i];

                if(uNode.getParent() != null && uNode.getParent().getId() == v) {
                    continue;
                }

                if(!visited[v]) {
                    Node vNode = new Node(v, d[v], uNode.getDepth() + 1, uNode);
                    stack.add(vNode);
                    cntOfSubtreeConnectedEdges++;
                }
            }

            uNode.setActualDegree(cntOfSubtreeConnectedEdges);

            if(cntOfSubtreeConnectedEdges == 0) {
                leafNodes.add(uNode);
            }
        }

        return leafNodes;
    }

    static class Node {
        private int id;
        private int expectedDegree;
        private int actualDegree;
        private int depth;
        private Node parent;

        public Node(int id, int expectedDegree, int depth) {
            this.id = id;
            this.expectedDegree = expectedDegree;
            this.depth = depth;
            this.parent = null;
        }

        public Node(int id, int expectedDegree, int depth, Node parent) {
            this.id = id;
            this.expectedDegree = expectedDegree;
            this.depth = depth;
            this.parent = parent;
        }

        public int getId() {
            return id;
        }

        public int getExpectedDegree() {
            return expectedDegree;
        }

        public void setActualDegree(int actualDegree) {
            this.actualDegree = actualDegree;
        }

        public int getActualDegree() {
            return actualDegree;
        }

        public int getDepth() {
            return depth;
        }

        public Node getParent() {
            return parent;
        }
    }
}
