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;
struct edge {
  long long x, y, id;
  edge &operator=(const edge &ex) {
    x = ex.x;
    y = ex.y;
    id = ex.id;
    return *this;
  }
};
const long long mxn = 300010;
struct graph {
  long long p;
  edge a[mxn << 1];
  long long head[mxn], nxt[mxn << 1];
  void addedge(long long o, const edge &ex) {
    a[++p] = ex;
    nxt[p] = head[o];
    head[o] = p;
    return;
  }
};
long long i, j, k;
long long x, y, z, xx, xy, xz, yx, yy, yz;
bool blx, bly, blz;
edge ex, ey, ez;
long long m, n, p;
graph a, b;
long long c[mxn];
bool vst[mxn];
long long sz[mxn];
long long slc[mxn];
vector<long long> ans;
void dfsa(long long o) {
  long long i, j;
  long long x, y;
  edge ex;
  vst[o] = true;
  for (x = a.head[o]; x; x = a.nxt[x]) {
    ex = a.a[x];
    if (!vst[ex.y]) {
      b.addedge(o, ex);
      dfsa(ex.y);
    }
  }
  return;
}
void dfsb(long long o, long long ep) {
  long long i, j;
  long long x, y;
  edge ex;
  for (x = b.head[o]; x; x = b.nxt[x]) {
    ex = b.a[x];
    dfsb(ex.y, ex.id);
    sz[o] += sz[ex.y];
  }
  if (sz[o] & 1) {
    slc[ep] = true;
  }
  return;
}
int main() {
  scanf("%lld%lld", &n, &m);
  blx = false;
  x = 0;
  for (i = 1; i <= n; i++) {
    scanf("%lld", &c[i]);
    if (c[i] == -1) {
      blx = true;
    } else {
      x += c[i];
    }
  }
  if (!blx && x & 1) {
    printf("-1\n");
  } else {
    if (x & 1) {
      for (i = 1; ~c[i]; i++) {
      }
      c[i] = 1;
    }
    for (i = 1; i <= n; i++) {
      if (c[i] == -1) {
        c[i] = 0;
      } else if (c[i] == 1) {
        sz[i] = 1;
      }
    }
    for (i = 1; i <= m; i++) {
      scanf("%lld%lld", &x, &y);
      a.addedge(x, (edge){x, y, i});
      a.addedge(y, (edge){y, x, i});
    }
    dfsa(1);
    dfsb(1, 0);
    for (i = 1; i <= m; i++) {
      if (slc[i]) {
        ans.push_back(i);
      }
    }
    printf("%d\n", (int)ans.size());
    for (i = 0; i < ans.size(); i++) {
      printf("%lld\n", ans[i]);
    }
  }
  return 0;
}
