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.awt.geom.Rectangle2D;
import java.util.*;
import java.io.*;

public class Main {

    static class TaskF {
        static int V;
        static int E;
        static int[][] matrix;
        static int[] values;
        static boolean[] needTocCheck;
        static ArrayList<Integer> ans;
        static ArrayList<Integer> current_ans;
        static int[][] edges;

        void solve(InputReader in, PrintWriter out) {
            V = in.nextInt();
            E = in.nextInt();
            values = new int[V];
            needTocCheck = new boolean[V];
            matrix = new int[V][V];
            edges = new int[E][3];
            boolean isMinusOne = true;
            for (int i = 0; i < V; i++) {
                int v = in.nextInt();
                values[i] = v;
                if (v == -1) {
                    needTocCheck[i] = true;
                    isMinusOne = false;
                }
            }

            //preparing...
            for (int i = 0; i < E; i++) {
                int from = in.nextInt() - 1;
                int to = in.nextInt() - 1;
                matrix[from][to] = 1;
                matrix[to][from] = 1;
                edges[i][0] = from;
                edges[i][1] = to;
            }

            for (int i = 0; i < V; i++) {
                if (!needTocCheck[i]) {
                    int count = 0;
                    for (int j = 0; j < V; j++) {
                        if (matrix[i][j] == 1)
                            count++;
                    }
                    if (count % 2 == values[i]) {
                        needTocCheck[i] = true;
                        isMinusOne = false;
                    }
                }
            }
            System.out.println(Arrays.toString(needTocCheck));
            if (isMinusOne) out.println(-1);
            else {
                ans = new ArrayList<>();
                current_ans = new ArrayList<>();

                // main logic
                for (int i = 0; i < needTocCheck.length; i++) {
                    if (needTocCheck[i]) {
                        current_ans.clear();
                        bfs(i);
                        if (current_ans.size() > ans.size()) {
                            ans.clear();
                            ans.addAll(current_ans);
                        }
                    }
                }

                // print
                out.println(ans.size());
                if (ans.size() > 0) {
                    for (int x : ans) {
                        out.print(x);
                        out.print(" ");
                    }
                }
            }
        }


        static void bfs(int s) {
            MyQueue q = new MyQueue(V + 10);
            q.push(s);
            while (!q.isEmpty()) {
                int v = q.pop();
                needTocCheck[v] = false;

                current_ans.add(v);
                for (int i = 0; i < matrix[v].length; i++) {
                    if (matrix[v][i] != 0) {
                        if (needTocCheck[i]) {
                            q.push(i);
                            for (int j = 0; j < edges.length; j++) {
                                if(edges[j][1] == i && edges[j][0] == v) ans.add(edges[j][0]+1);
                            }
                        }
                    }
                }
            }
        }

        static class MyQueue {
            private int[] arrayQueue;
            private int front;
            private int rear;
            private int nItems;
            private int maxSize;

            public MyQueue(int x) {
                arrayQueue = new int[x];
                nItems = 0;
                front = 0;
                rear = -1;
                maxSize = x;
            }

            public void push(int x) {
                if (rear == maxSize - 1)
                    rear = -1;
                rear++;
                arrayQueue[rear] = x;
                nItems++;
            }

            public int pop() {
                int tmp = arrayQueue[front];
                if (front == maxSize - 1)
                    front = 0;
                front++;
                nItems--;
                return tmp;
            }

            public int peek() {
                return arrayQueue[front];
            }

            public boolean isEmpty() {
                return nItems == 0;
            }

            public boolean isFull() {
                return nItems == maxSize;
            }
        }

        static class Stack {
            int size;
            private int index;
            private int[] stackArray;


            public Stack(int size) {
                this.size = size;
                this.index = -1;
                this.stackArray = new int[size];
            }

            public void push(int x) {
                index++;
                stackArray[index] = x;
            }

            public int peek() {
                return stackArray[index];
            }

            public int pop() {
                index--;
                return stackArray[index + 1];
            }

            public boolean isEmpty() {
                return index == -1;
            }

            public boolean isFull() {
                return index == size - 1;
            }

            public void clear() {
                index = -1;
            }

        }

    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskF solver = new TaskF();
        solver.solve(in, out);
        out.close();
    }

    static private class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

    }
}
