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.InputMismatchException;
import java.io.IOException;
import java.util.Collections;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
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);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        ArrayList<Integer> ans;
        int[] d;
        ArrayList<Integer>[] edges;
        boolean[] visited;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.readInt();
            int m = in.readInt();
            ans = new ArrayList<>();
            edges = new ArrayList[n + 1];
            visited = new boolean[n + 1];
            for (int i = 0; i <= n; i++) edges[i] = new ArrayList<>();
            d = new int[n + 1];
            int sum = 0, last = -1;
            for (int i = 1; i <= n; i++) {
                int td = in.readInt();
                if (td == -1) {
                    last = i;
                }
                d[i] = Math.max(0, td);
                sum += d[i];
            }
            if (sum % 2 != 0 && last < 0) {
                out.println(-1);
                return;
            }
            if (sum % 2 == 1) d[last] = 1;
            for (int i = 0; i < m; i++) {
                int u = in.readInt();
                int v = in.readInt();
                edges[u].add(v);
                edges[u].add(i + 1);
                edges[v].add(u);
                edges[v].add(i + 1);
            }
            go(1);
            out.println(ans.size());
            Collections.sort(ans);
            for (int i : ans) out.println(i);
        }

        boolean go(int index) {
            if (visited[index]) return false;

            visited[index] = true;
            int sum = 0;
            for (int i = 0; i < edges[index].size(); i += 2) {
                if (go(edges[index].get(i))) {
                    sum++;
                    ans.add(edges[index].get(i + 1));
                }
            }
            return sum % 2 != d[index];
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}

