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;
int n, m, d[300010], chk = 0, hv = 0;
int cnt = 0, hed[300010], to[600010], nxt[600010];
int ans[300010], len = 0;
bool vis[300010];
inline void add(int x, int y) {
  to[++cnt] = y, nxt[cnt] = hed[x], hed[x] = cnt;
}
int dfs(int u) {
  vis[u] = 1;
  int tot = 0;
  for (int i = hed[u]; i; i = nxt[i]) {
    if (vis[to[i]]) continue;
    if (dfs(to[i])) tot ^= 1, ans[++len] = i / 2 + 1;
  }
  if (d[u] == -1) tot = 0;
  return tot == d[u] ? 0 : 1;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &d[i]);
    if (d[i] == -1)
      hv = i;
    else
      chk ^= d[i];
  }
  if (chk && !hv) {
    puts("-1");
    return 0;
  }
  for (int i = 1, x, y; i <= m; i++)
    scanf("%d%d", &x, &y), add(x, y), add(y, x);
  if (!hv) hv = 1;
  dfs(hv);
  sort(ans + 1, ans + len + 1);
  printf("%d\n", len);
  for (int i = 1; i <= len; i++) printf("%d\n", ans[i]);
  return 0;
}
