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>
const int maxn = 3e5;
int ans[maxn], vis[maxn], d[maxn];
int n, m, cnt, ct;
int read() {
  char ch = getchar();
  int x = 0, f = 1;
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
struct edge {
  int to, num;
  edge(int x, int y) : to(x), num(y) {}
  edge() {}
};
std::vector<edge> to[maxn];
void add_edge(int u, int v) {
  to[u].push_back(edge(v, ++cnt));
  to[v].push_back(edge(u, cnt));
}
int dfs(int x) {
  int ret = d[x];
  vis[x] = 1;
  for (int i = 0; i < to[x].size(); i++) {
    int v = to[x][i].to;
    if (!vis[v] && dfs(v)) {
      ret ^= 1;
      ans[++cnt] = to[x][i].num;
    }
  }
}
int main() {
  n = read();
  m = read();
  int flag = 0;
  for (int i = 1; i <= n; i++) {
    d[i] = read();
    if (d[i] == 1) d[++ct] = i;
    if (d[i] == -1) d[flag = i] = 0;
  }
  if ((ct & 1) && !flag) return puts("-1") & 0;
  if (ct & 1 && flag) d[flag] = 1;
  for (int i = 1; i <= m; i++) add_edge(read(), read());
  cnt = 0;
  dfs(1);
  printf("%d\n", cnt);
  for (int i = 1; i <= cnt; i++) printf("%d\n", ans[i]);
  return 0;
}
