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.*;
import java.io.*;

public class D
{
   public static void main(String[] args) throws IOException
   {
      //FastReader infile = new FastReader("test.txt");
      FastReader infile = new FastReader(System.in);
      int n = infile.nextInt();
      int m = infile.nextInt();
      Node[] nodes = new Node[n+1];
      for(int x = 1; x <= n; x++)
         nodes[x] = new Node(infile.nextInt(), 1);
      int[][] edges = new int[m][2];
      for(int x = 0; x < m; x++)
      {
         int a = edges[x][0] = infile.nextInt();
         int b = edges[x][1] = infile.nextInt();
         nodes[a].paths.add(nodes[b]);
         nodes[b].paths.add(nodes[a]);
      }
      boolean zero = false;
      boolean[] good = new boolean[n+1];
      for(int x = 1; x <= n; x++)
         if(nodes[x].value==-1)
            zero = good[x] = true;
         else if(nodes[x].paths.size()%2==nodes[x].value)
            good[x] = true;
      if(zero)
      {
         System.out.println(0);
         System.exit(0);
      }
      for(int x = 0; x < m; x++)
         if(good[edges[x][0]]&&good[edges[x][1]])
         {
            System.out.println(1);
            System.out.println(x+1);
            System.exit(0);
         }  
      System.out.println(-1);
   }
}
class Node
{
   int value;
   int index;
   ArrayList<Node> paths = new ArrayList<Node>();
   public Node(int v, int i)
   {
      value = v;
      index = i;
   }
   public String toString()
   {
      return index+" "+value;
   }
}
class FastReader
{
   BufferedReader br;
   StringTokenizer st;

   public FastReader(String file) throws IOException
   {
      br = new BufferedReader(new FileReader(file));
   }
 
   public FastReader(InputStream i) throws IOException
   {
      br = new BufferedReader(new InputStreamReader(System.in));
   }
   boolean hasNext()
   {
      while (st == null || !st.hasMoreElements())
      {
         try
         {
            st = new StringTokenizer(br.readLine());
         }
         catch (Exception  e)
         {
            return false;
         }
      }
      return true;
   }
 
   String next()
   {
      while (st == null || !st.hasMoreElements())
      {
         try
         {
            st = new StringTokenizer(br.readLine());
         }
         catch (IOException  e)
         {
            e.printStackTrace();
         }
      }
      return st.nextToken();
   }
 
   int nextInt()
   {
      return Integer.parseInt(next());
   }
 
   long nextLong()
   {
      return Long.parseLong(next());
   }
 
   double nextDouble()
   {
      return Double.parseDouble(next());
   }
 
   String nextLine()
   {
      String str = "";
      try
      {
         str = br.readLine();
      }
      catch (IOException e)
      {
         e.printStackTrace();
      }
      return str;
   }
}