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 maxn = 3e5 + 10;
vector<pair<int, int> > adj[maxn];
vector<int> eggs;
bool mark[maxn];
int d[maxn];
void dfs(int u, int f = -1, int x = -1) {
  mark[u] = 1;
  for (auto v : adj[u]) {
    if (!mark[v.first]) {
      dfs(v.first, u, v.second);
    }
  }
  if (f != -1) {
    if (d[u] == 1) {
      d[f] = 1 - d[f];
      eggs.push_back(x);
    }
  } else {
    if (d[u] != 0) {
      cout << "OOPS!";
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  int s = 0;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    d[i] = t;
    if (t != -1) {
      s = (s + t) % 2;
    }
  }
  for (int i = 0; i < n; i++) {
    if (s == 1 && d[i] == -1) {
      d[i] = 1;
      s = 0;
    }
    if (s == 0 && d[i] == -1) {
      d[i] = 0;
    }
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    adj[u].push_back({v, i + 1});
    adj[v].push_back({u, i + 1});
  }
  if (s == 1) {
    cout << -1;
    return 0;
  }
  dfs(0);
  cout << eggs.size() << '\n';
  for (auto i : eggs) {
    cout << i << '\n';
  }
}
