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 = 300 * 1000 + 10;
int d[MAXN], deg[MAXN];
bool mark[MAXN];
vector<pair<int, int> > adj[MAXN];
vector<int> ans;
void dfs(int x) {
  mark[x] = true;
  for (int i = 0; i < ((int)(adj[x]).size()); i++) {
    int v = adj[x][i].first, idx = adj[x][i].second;
    if (mark[v]) continue;
    dfs(v);
    if (d[v] != -1 && d[v] != deg[v]) {
      ans.push_back(idx);
      deg[x] ^= 1;
      deg[v] ^= 1;
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int root = 0;
  for (int i = 0; i < n; i++) {
    cin >> d[i];
    if (d[i] == -1) root = i;
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    adj[x].push_back(make_pair(y, i));
    adj[y].push_back(make_pair(x, i));
  }
  dfs(root);
  if (d[root] != -1 && d[root] != deg[root]) {
    cout << -1 << endl;
  } else {
    cout << ((int)(ans).size()) << endl;
    for (int i = 0; i < ((int)(ans).size()); i++) cout << ans[i] + 1 << ' ';
    cout << endl;
  }
  return 0;
}
