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 javax.print.attribute.standard.MediaPrintableArea;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.io.*;
import java.util.*;
/**
 * Created by Firеfly on 1/1/2017.
 */
public class Task {
    public static void main(String[] args) throws IOException {
        Emaxx emaxx = new Emaxx();
    }
}


class Emaxx {
    FScanner fs;
    int m ,n, k, x, y, EXISTS;
    static int maxim =0;
    int[][] results;
    ArrayList[] Graph;
    int[] sizes;
    static double ans = 0;
    boolean[] were;
    Emaxx() throws IOException {
        FScanner fs = new FScanner(new InputStreamReader(System.in));
        // pw = new PrintWriter(new FileWriter("arithnumbers.out"));
        //  fs = new FScanner(new FileReader("C:\\Users\\Firеfly\\Desktop\\New Text Document.txt"));
        //     fs = new FScanner(new FileReader("input.txt"));;
        //       pw = new PrintWriter("output.txt");
        PrintWriter pw = new PrintWriter(System.out);
        n = fs.nextInt();
        m = fs.nextInt();
        int[] vert = new int[n];
        for (int i =0 ; i<n; i++)
            vert[i] = fs.nextInt();
        Graph = new ArrayList[n];
        for (int i =0 ;i<n; i++)
            Graph[i] = new ArrayList();
        for (int i =0 ; i<m; i++)
        {
            int q = fs.nextInt()-1;
            int w = fs.nextInt()-1;
            Graph[q].add(new Pair(w, i+1));
            Graph[w].add(new Pair(q, i+1));
        }
        for (int i = 0 ;i<n; i++) {
            if (vert[i] == -1)
            {
                System.out.println(0);
                System.exit(0);
            }
        }
        ArrayList<Integer>[] doubles = new ArrayList[n];
        ArrayList<Integer>[] ones = new ArrayList[n];
        HashSet<Integer>[] dots = new HashSet[n];
        for (int i =0 ; i<n; i++) {
            if (vert[i] == 0)
            {
                doubles[i] = new ArrayList<>();
                ones[i] = new ArrayList<>();
                dots[i] = new HashSet<>();
            }
        }
        for (int i =0 ; i<n; i++) {
            if (vert[i] == 1) {
                for (int j = 0; j<Graph[i].size(); j++) {
                    if (vert[((Pair)Graph[i].get(j)).x] == 1) {
                        System.out.println(1);
                        System.out.println(((Pair)Graph[i].get(j)).y);
                        System.exit(0);
                    }
                }
            } else if (vert[i] == 0) {
                for (int j = 0; j<Graph[i].size(); j++) {
                    if (vert[((Pair)Graph[i].get(j)).x] == 1) {
                        ones[i].add(((Pair)Graph[i].get(j)).x);
                    } else {
                        if (dots[i].contains(((Pair)Graph[i].get(j)).x)) {
                            System.out.println(2);
                            System.out.println(((Pair)Graph[i].get(j)).y);
                            int s = ((Pair)Graph[i].get(j)).x;
                            for (int f = 0; f<Graph[i].size(); f++) {
                                if (((Pair)Graph[i].get(f)).x == s)
                                {
                                    System.out.println(((Pair)Graph[i].get(f)).y);
                                    System.exit(0);
                                }
                            }
                        } else {
                            dots[i].add(((Pair)Graph[i].get(j)).x);
                            doubles[i].add(((Pair)Graph[i].get(j)).x);
                        }
                    }
                }
            }
        }
        for (int i =0 ; i<n; i++) {
            if (vert[i] == 0)
                Collections.sort(ones[i]);
        }
        boolean[] used = new boolean[n];
        for (int i = 0; i<n; i++) {
            if (vert[i] !=0)
                continue;
            used[i] = true;
            for (int j = 0; j<doubles[i].size(); j++) {
                if (!used[doubles[i].get(j)]) {
                    for (int f = 0; f < doubles[i].size(); f++) {
                        if (dots[doubles[i].get(j)].contains(doubles[i].get(f))) {
                            System.out.println(3);
                            int first = i;
                            int second = doubles[i].get(j);
                            int third = doubles[i].get(f);
                            for (int q = 0; q < Graph[first].size(); q++) {
                                if (((Pair) Graph[first].get(q)).x == second) {
                                    System.out.println(((Pair) Graph[first].get(q)).y);
                                    break;
                                }
                            }
                            for (int q = 0; q < Graph[first].size(); q++) {
                                if (((Pair) Graph[first].get(q)).x == third) {
                                    System.out.println(((Pair) Graph[first].get(q)).y);
                                    break;
                                }
                            }
                            for (int q = 0; q < Graph[second].size(); q++) {
                                if (((Pair) Graph[second].get(q)).x == third) {
                                    System.out.println(((Pair) Graph[second].get(q)).y);
                                    break;
                                }
                            }
                            System.exit(0);
                        }
                    }
                    if (ones[doubles[i].get(j)].size() > 0) {
                        for (int q1 = 0; q1 < ones[i].size(); q1++) {
                            if (Collections.binarySearch(ones[doubles[i].get(j)], ones[i].get(q1))<0) {
                                int s1 = ones[i].get(q1);
                                int s2 = i;
                                int s3 = doubles[i].get(j);
                                int s4 = ones[s3].get(0);
                                System.out.println(3);
                                for (int q = 0; q<Graph[s1].size(); q++) {
                                    if (((Pair)Graph[s1].get(q)).x == s2)
                                    {
                                        System.out.println(((Pair)Graph[s1].get(q)).y);
                                        break;
                                    }
                                }
                                for (int q = 0; q<Graph[s2].size(); q++) {
                                    if (((Pair)Graph[s2].get(q)).x == s3)
                                    {
                                        System.out.println(((Pair)Graph[s2].get(q)).y);
                                        break;
                                    }
                                }
                                for (int q = 0; q<Graph[s3].size(); q++) {
                                    if (((Pair)Graph[s3].get(q)).x == s4)
                                    {
                                        System.out.println(((Pair)Graph[s3].get(q)).y);
                                        break;
                                    }
                                }

                                System.exit(0);
                            }
                        }
                    }
                }
            }
        }
        System.out.println(-1);
        pw.close();
    }

    int gcd (int a, int b) {
        if (b == 0)
            return a;
        else
            return gcd (b, a % b);
    }





    int BIN_SEARCH(ArrayList<Integer> list, FScanner fs) throws IOException {
        int l = 0;
        int r = list.size()-1;
        while (l<r) {
            int mid = (l+r)/2;
            System.out.print("? ");
            System.out.flush();
                for (int i = l; i<=mid; i++) {
                    System.out.print(list.get(i) + " ");
                    System.out.flush();
                }
            System.out.println();
System.out.flush();
            int ans = fs.nextInt();
            if (ans == y || ans == EXISTS)
                r = mid;
            else l = mid+1;
        }
        return r;
    }


    int gcd (int a, int b, INt x, INt y) {
        if (a == 0) {
            x.x = 0; y.x = 1;
            return b;
        }
        INt x1 = new INt(0), y1= new INt(0);
        int d = gcd (b%a, a, x1, y1);
        x.x = y1.x - (b / a) * x1.x;
        y.x = x1.x;
        return d;
    }


}

class INt implements Comparable<INt> {
    int x;
    INt(int x1) {
        x = x1;
    }

    @Override
    public int compareTo(INt iNt) {
        return Integer.compare(x, iNt.x);
    }
}

class Triple {
    int x, y, c;
    Triple(int x1, int y1, int c1) {
        x = x1; y = y1; c = c1;
    }


}
class Pair implements Comparable<Pair>{
    int x, y;
    Pair(int x1, int y1) {x = x1; y = y1;}
    Pair(){}
    @Override
    public int compareTo(Pair o) {
        return Integer.compare(x, o.x);
    }
}

class Algs {
    public static int[] Z_f(char[] s) {
        int[] zf = new int[s.length];
        zf[0] = -1;
        int l = 0, r= 0;
        for (int i = 1; i<s.length; i++) {
            if (i>r)
            {
                int g = i;
                while (g < s.length && s[g] == s[g-i])
                    g++;
                if (g == i)
                    continue;
                l = i;
                r = g-1;
                zf[i] = g-i;
            } else {
                if (zf[i-l]<=r-i+1)
                    zf[i] = zf[i-l];
                else {
                    int g = r+1;
                    while (g <s.length && s[g] == s[g-i])
                        g++;
                    if (g == r+1)
                        zf[i] = r-i+1;
                    else {
                        zf[i] = g-i;
                        r = g-1;
                        l = i;
                    }
                }
            }
        }
        return zf;
    }
}



class FScanner {
    BufferedReader br;
    StringTokenizer st;
    FScanner(InputStreamReader isr) {
        br = new BufferedReader(isr);
    }

    FScanner(FileReader fr) {
        br = new BufferedReader(fr);
    }

    String nextToken() throws IOException{
        while (st == null || !st.hasMoreTokens()) {
            String s = br.readLine();
            if (s == null)
                return null;
            st = new StringTokenizer(s);
        }
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextLine() throws IOException {
        return br.readLine();
    }

    char nextChar() throws IOException {
        return (char) br.read();
    }
}
