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 = 300050;
int n, m, s, cnt, tot = 1, all, u, v, d[N], vis[N], head[N];
bool f = 0;
struct node {
  int v, nxt;
} e[N << 1];
void add(int u, int v) {
  e[++tot].v = v;
  e[tot].nxt = head[u];
  head[u] = tot;
  e[++tot].v = u;
  e[tot].nxt = head[v];
  head[v] = tot;
}
vector<int> ans;
bool dfs(int u) {
  vis[u] = 1;
  int v = 0, now = d[u];
  for (int i = head[u]; i; i = e[i].nxt) {
    v = e[i].v;
    if (vis[v]) continue;
    if (dfs(v)) {
      ans.push_back(i >> 1);
      all++;
      now ^= 1;
    }
  }
  if (d[u] == -1) now = 0;
  return now;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &d[i]);
    if (d[i] < 0) {
      f = 1;
      s = i;
    }
    cnt += d[i];
  }
  if (!f && cnt % 2 == 1) {
    printf("-1\n");
    return 0;
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    add(u, v);
  }
  if (!s)
    for (int i = 1; i <= n; i++)
      if (d[i] == 1) {
        s = i;
        break;
      }
  dfs(s);
  printf("%d\n", all);
  for (int i = 0; i < all; i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}
