#include <bits/stdc++.h>
using namespace std;
int d[300005], target[600005], pre[600005], last[300005], tot = 1, ans[300005];
bool visited[300005];
void add(int x, int y) {
  target[++tot] = y;
  pre[tot] = last[x];
  last[x] = tot;
}
void dfs(int x) {
  visited[x] = 1;
  for (int i = last[x]; i; i = pre[i]) {
    int tar = target[i];
    if (visited[tar]) continue;
    dfs(tar);
    if (d[tar]) ans[++ans[0]] = (i >> 1), d[x] ^= 1, d[tar] ^= 1;
  }
}
int main() {
  int n, m, sum = 0, sum2 = 0, x, y;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &d[i]);
    if (d[i] == -1)
      sum2++;
    else
      sum ^= d[i];
  }
  if (sum == 1 && sum2 == 0) {
    puts("-1");
    return 0;
  }
  for (int i = 1; i <= n; i++)
    if (d[i] == -1) {
      if (sum == 1 && sum2)
        d[i] = 1, sum2 = 0;
      else
        d[i] = 0;
    }
  for (int i = 1; i <= m; i++) scanf("%d%d", &x, &y), add(x, y), add(y, x);
  dfs(1);
  sort(ans + 1, ans + ans[0] + 1);
  printf("%d\n", ans[0]);
  for (int i = 1; i <= ans[0]; i++) printf("%d\n", ans[i]);
  return 0;
}
