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;
inline int read() {
  int x = 0;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    ;
  for (; ch <= '9' && ch >= '0'; x = x * 10 + ch - 48, ch = getchar())
    ;
  return x;
}
int i, j, k, m, n, x, y, root, d[300030], cnt, last[300030], du[300030], ct,
    vis[300030], ce[300030], ans[300030];
struct edge {
  int to, next, id;
} e[300030 << 1];
inline void add(int u, int v) {
  e[++cnt] = (edge){v, last[u], i}, last[u] = cnt, ++du[v];
  e[++cnt] = (edge){u, last[v], i}, last[v] = cnt, ++du[u];
}
void dfs(int x, int fa, int fe) {
  vis[x] = 1;
  int ct = 0;
  for (int i = last[x], y; i; i = e[i].next)
    if ((y = e[i].to) != fa && !vis[y])
      if (dfs(y, x, e[i].id), ce[e[i].id]) ++ct;
  if (d[x] != -1 && (ct % 2) ^ d[x]) ce[fe] = 1, ans[++*ans] = fe;
}
int main() {
  for (n = read(), m = read(), i = 1; i <= n; ++i)
    if (scanf("%d", &d[i]), d[i] == -1) root = i;
  for (i = 1; i <= m; ++i) add(read(), read());
  for (i = 1; i <= n; ++i)
    if (d[i] != -1 && du[i] % 2 == 0) ++ct;
  if (root)
    dfs(root, 0, 0);
  else if (ct % 2 == 0)
    dfs(1, 0, 0);
  else
    return puts("-1"), 0;
  printf("%d\n", *ans);
  for (sort(ans + 1, ans + *ans + 1), i = 1; i <= *ans; ++i)
    printf("%d ", ans[i]);
}
