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 N = 300050;
int pre[N], nxt[N * 2], to[N * 2], cnt = 0;
int d[N];
void addEdge(int x, int y) {
  nxt[cnt] = pre[x];
  to[pre[x] = cnt++] = y;
}
int ansc = 0, ansv[N];
bool vis[N];
int dfs(int x) {
  int ans = d[x];
  vis[x] = true;
  for (int i = pre[x]; ~i; i = nxt[i])
    if (!vis[to[i]])
      if (dfs(to[i])) {
        ans ^= 1;
        ansv[ansc++] = (i >> 1) + 1;
      }
  return ans;
}
int main() {
  int n, m, x, y;
  scanf("%d%d", &n, &m);
  int d1 = -1, cnt1 = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &d[i]);
    if (d[i] == -1) d[d1 = i] = 0;
    if (d[i] == 1) ++cnt1;
  }
  if ((cnt1 & 1) && d1 == -1)
    return puts("-1") & 0;
  else if (cnt1 & 1)
    d[d1] = 1;
  memset(pre, -1, sizeof pre);
  while (m--) {
    scanf("%d%d", &x, &y);
    addEdge(--x, --y);
    addEdge(y, x);
  }
  dfs(0);
  printf("%d\n", ansc);
  for (int i = 0; i < ansc; ++i) printf("%d ", ansv[i]);
  return 0;
}
