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;
int d[400000];
vector<pair<int, int> > E[400000];
bool used[400000];
vector<int> ans;
int dfs(int v, int p) {
  used[v] = true;
  int x = d[v];
  for (auto u : E[v]) {
    if (used[u.first]) continue;
    x ^= dfs(u.first, v);
  }
  if (x) {
    for (auto u : E[v]) {
      if (u.first == p) {
        ans.push_back(u.second);
        break;
      }
    }
  }
  return x;
}
int main() {
  int n, m;
  cin >> n >> m;
  int sum = 0;
  for (int i = 0; i < (n); i++) {
    scanf("%d", &d[i]);
    if (d[i] >= 0) sum ^= d[i];
  }
  for (int i = 0; i < (m); i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    b--;
    E[a].push_back(pair<int, int>(b, i));
    E[b].push_back(pair<int, int>(a, i));
  }
  if (sum == 1) {
    for (int i = 0; i < (n); i++) {
      if (d[i] == -1) {
        d[i] = 1;
        sum = 0;
        break;
      }
    }
    if (sum == 1) {
      puts("-1");
      return 0;
    }
  }
  for (int i = 0; i < (n); i++) {
    if (d[i] == -1) d[i] = 0;
  }
  dfs(0, -1);
  sort(ans.begin(), ans.end());
  cout << ans.size() << endl;
  for (int i : ans) printf("%d ", i + 1);
  cout << endl;
}
