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 val[300001], sav, nr[300001], nr1, n, m, x, y;
bool viz[300001];
vector<pair<int, int> > V[300001];
int dfs(int nod) {
  int x = 0, aux;
  viz[nod] = 1;
  for (int i = 0; i < V[nod].size(); i++) {
    if (viz[V[nod][i].first] == 0) {
      aux = dfs(V[nod][i].first);
      x = (x + aux) % 2;
      if (aux == 1) nr[V[nod][i].second]++;
    }
  }
  if (val[nod] == 1) x = (x + 1) % 2;
  return x;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> val[i];
    if (val[i] == -1) sav = i;
    if (val[i] == 1) nr1++;
  }
  for (int i = 1; i <= m; i++) {
    cin >> x >> y;
    V[x].push_back(make_pair(y, i));
    V[y].push_back(make_pair(x, i));
  }
  if (sav == 0 && nr1 % 2 == 1) {
    cout << -1;
    return 0;
  }
  if (sav == 0) sav = 1;
  dfs(sav);
  int k = 0;
  for (int i = 1; i <= n; i++) {
    nr[i] %= 2;
    if (nr[i] == 1) k++;
  }
  cout << k << '\n';
  for (int i = 1; i <= n; i++) {
    if (nr[i] == 1) cout << i << '\n';
  }
  return 0;
}
