#include <bits/stdc++.h>
using namespace std;
const int maxN = 300010;
int d[maxN];
bool v[maxN];
vector<pair<int, int> > gph[maxN];
vector<int> ans;
int dfs(int x) {
  v[x] = true;
  int p = d[x];
  for (auto &e : gph[x]) {
    int y = e.first;
    if (!v[y] && dfs(y)) {
      ans.push_back(e.second);
      p ^= 1;
    }
  }
  if (d[x] == -1) return 0;
  return p;
}
int main() {
  int n, m, i, f = -1, p = 0;
  scanf("%d %d", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%d", d + i);
    if (d[i] == -1)
      f = i;
    else
      p ^= d[i];
  }
  for (i = 1; i <= m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    gph[u].push_back(pair<int, int>(v, i));
    gph[v].push_back(pair<int, int>(u, i));
  }
  if (f == -1) {
    if (p) {
      puts("-1");
      return 0;
    } else
      f = 1;
  }
  dfs(f);
  sort(ans.begin(), ans.end());
  printf("%d\n", ans.size());
  for (auto x : ans) printf("%d\n", x);
}
