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

#include <bits/stdc++.h>
using namespace std;
template <typename T>
int desc(const void* elem1_pointer, const void* elem2_pointer) {
  T f = *((T*)elem1_pointer);
  T s = *((T*)elem2_pointer);
  if (f > s) return -1;
  if (f < s) return 1;
  return 0;
};
struct edge {
  int u;
  int v;
  int next;
};
int main() {
  int n;
  scanf("%d", &n);
  int m;
  scanf("%d", &m);
  vector<int> badV;
  int d[3 * 100000 + 1];
  int dCur[3 * 100000 + 1];
  for (int i = 0; i < n; i++) {
    int di;
    scanf("%d", &di);
    d[i] = di;
    if (di == 1) badV.push_back(i);
    dCur[i] = 0;
  }
  vector<edge> edges;
  edge start;
  start.u = -1;
  start.v = -1;
  start.next = m > 0 ? 0 : -1;
  for (int i = 0; i < m; i++) {
    int u;
    scanf("%d", &u);
    u--;
    int v;
    scanf("%d", &v);
    v--;
    edge e;
    e.u = u;
    e.v = v;
    e.next = i == m - 1 ? -1 : i + 1;
    edges.push_back(e);
  }
  vector<int> goodEdges;
  while (badV.size() > 0) {
    int v = badV.back();
    badV.pop_back();
    if (dCur[v] == d[v]) continue;
    if (start.next == -1) {
      printf("%d\n", -1);
      ;
      return 0;
    }
    edge& prev = start;
    while (prev.next > -1) {
      auto e = edges[prev.next];
      int u = -1;
      if (e.v == v) u = e.u;
      if (e.u == v) u = e.v;
      if (u == -1) {
        prev = e;
        continue;
      }
      if (d[u] != -1) {
        badV.push_back(u);
      }
      dCur[u] = (dCur[u] + 1) % 2;
      dCur[v] = (dCur[v] + 1) % 2;
      goodEdges.push_back(prev.next);
      prev.next = e.next;
      break;
    }
  }
  printf("%d\n", (int)goodEdges.size());
  ;
  for (int i = 0; i < goodEdges.size(); i++) {
    printf("%d\n", goodEdges[i] + 1);
    ;
  }
  return 0;
}
