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<vector<pair<int, int> > > edgesForVertex;
  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;
    edgesForVertex.push_back(vector<pair<int, int> >());
  }
  int usedEdges[3 * 100000 + 1];
  for (int i = 0; i < m; i++) {
    int u;
    scanf("%d", &u);
    u--;
    int v;
    scanf("%d", &v);
    v--;
    usedEdges[i] = 0;
    edgesForVertex[u].push_back(pair<int, int>(v, i));
    edgesForVertex[v].push_back(pair<int, int>(u, i));
  }
  if (m == 0 && badV.size() > 0) {
    printf("%d\n", -1);
    ;
    return 0;
  }
  vector<int> goodEdges;
  while (badV.size() > 0) {
    int v = badV.back();
    badV.pop_back();
    if (dCur[v] == d[v] || d[v] == -1) continue;
    int resolved = 0;
    for (int i = 0; i < edgesForVertex[v].size(); i++) {
      if (usedEdges[i]) continue;
      int u = edgesForVertex[v][i].first;
      int edgeId = edgesForVertex[v][i].second;
      if (d[u] != -1) {
        badV.push_back(u);
        dCur[u] = (dCur[u] + 1) % 2;
      }
      dCur[v] = (dCur[v] + 1) % 2;
      goodEdges.push_back(edgeId);
      usedEdges[i] = 1;
      resolved = 1;
      break;
    }
  }
  printf("%d\n", (int)goodEdges.size());
  ;
  for (int i = 0; i < goodEdges.size(); i++) {
    printf("%d\n", goodEdges[i] + 1);
    ;
  }
  return 0;
}
