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


/**
 * @author: Mehul Raheja
 */

import java.util.*;
import java.io.*;

public class LehaAndGame{

    /*
        Runtime = O()
     */
    static int N, M, K;
    static String s;
    static StringTokenizer st;
    static int[] d;
    
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));   
        st = new StringTokenizer(br.readLine());
        int N = Integer.parseInt(st.nextToken());
        int M = Integer.parseInt(st.nextToken());
        st = new StringTokenizer(br.readLine());
        d =new int[N];
        for (int i = 0; i < N; i++) {
            d[i] = Integer.parseInt(st.nextToken());
            if(d[i] == 0 || d[i] == -1){
                System.out.println(0);
                System.exit(0);
            }
        }
        for (int i = 0; i < M; i++) {
            st = new StringTokenizer(br.readLine());
            int a = Integer.parseInt(st.nextToken());
            int b = Integer.parseInt(st.nextToken());
            if(d[a-1] == 1 && d[b-1] == 1){
                System.out.println(1);
                System.out.println(i+1);
                System.exit(0);
            }
        }
        System.out.println(-1);
    }    
}
