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>
std::map<std::pair<int, int>, int> hash;
int n, m;
struct edge {
  int to, next;
} e[300010];
int last[300010], et;
int deg[300010], sdeg[300010], k[300010];
bool comp(const int &i, const int &j) { return sdeg[i] < sdeg[j]; }
void add(int u, int v) {
  e[++et] = (edge){v, last[u]}, last[u] = et;
  e[++et] = (edge){u, last[v]}, last[v] = et;
  sdeg[u]++, sdeg[v]++;
}
int d[300010];
int cho[300010];
void calc(int u) {
  if (d[u] < 0) {
    for (int it = last[u]; it; it = e[it].next) {
      if (cho[(it + 1) >> 1]) continue;
      if ((d[e[it].to] >= 0 && (deg[e[it].to] & 1) != d[e[it].to])) {
        cho[(it + 1) >> 1] = 1;
        deg[u]++, deg[e[it].to]++;
      }
    }
    return;
  }
  int cnt = 0;
  for (int it = last[u]; it; it = e[it].next) {
    if (cho[(it + 1) >> 1]) continue;
    if ((d[e[it].to] >= 0 && (deg[e[it].to] & 1) != d[e[it].to])) {
      if ((d[u] >= 0 && (deg[u] & 1) != d[u])) {
        cho[(it + 1) >> 1] = 1;
        deg[u]++, deg[e[it].to]++;
      } else
        cnt++;
    }
  }
  cnt >>= 1, cnt <<= 1;
  for (int it = last[u], c = 1; it && c <= cnt; it = e[it].next) {
    if (cho[(it + 1) >> 1]) continue;
    if ((d[e[it].to] >= 0 && (deg[e[it].to] & 1) != d[e[it].to])) {
      cho[(it + 1) >> 1] = 1;
      deg[u]++, deg[e[it].to]++;
      c++;
    }
  }
  return;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", d + i), k[i] = i;
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    if (u == v) continue;
    std::pair<int, int> p = std::make_pair(std::max(u, v), std::min(u, v));
    if (!hash[p]) hash[p] = 1, add(u, v);
  }
  std::sort(k + 1, k + n + 1, comp);
  int flag = 1;
  for (int i = 1; i <= n; i++)
    if (d[k[i]] >= 0) calc(k[i]);
  for (int i = 1; i <= n; i++)
    if (d[k[i]] < 0) calc(k[i]);
  for (int i = 1; i <= n; i++)
    if ((d[i] >= 0 && (deg[i] & 1) != d[i])) flag = 0;
  if (!flag) {
    puts("-1");
    return 0;
  }
  int x = 0;
  for (int i = 1; i <= m; i++) x += cho[i];
  printf("%d\n", x);
  for (int i = 1; i <= m; i++)
    if (cho[i]) printf("%d ", i);
  return 0;
}
