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;
const int N = 3e5 + 10;
int n, m, cnt;
int d[N], h[N];
int ans[N << 1], tot;
bool vis[N];
struct edge {
  int to, next;
} e[N << 1];
inline void add(int from, int to) {
  e[++cnt] = (edge){to, h[from]};
  h[from] = cnt;
}
bool dfs(int x) {
  vis[x] = 1;
  bool res = d[x];
  for (int i = h[x]; i; i = e[i].next) {
    int v = e[i].to;
    if (vis[v]) continue;
    if (dfs(v)) ans[++tot] = (i + 1) / 2, res ^= 1;
  }
  if (d[x] == -1) res = 0;
  return res;
}
int main() {
  int be = -1, ok = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", d + i);
    if (d[i] == -1)
      be = i;
    else
      ok ^= d[i];
  }
  int u, v;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    add(u, v);
    add(v, u);
  }
  if (be == -1 && ok) {
    puts("-1");
    return 0;
  }
  if (be == -1) be = 1;
  dfs(be);
  printf("%d\n", tot);
  sort(ans + 1, ans + tot + 1);
  for (int i = 1; i <= tot; i++) printf("%d\n", ans[i]);
  return 0;
}
