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;
vector<long long> ans;
vector<pair<long long, long long> > v[1000001];
long long vis[1000001] = {0};
long long d[1000001];
long long dfs(long long cur) {
  vis[cur] = 1;
  long long i, j;
  long long temp = d[cur];
  for (i = 0; i < v[cur].size(); i++) {
    if (vis[v[cur][i].first] == 0) {
      if (dfs(v[cur][i].first) == 1) {
        temp = temp ^ 1;
        ans.push_back(v[cur][i].second);
      }
    }
  }
  return temp;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  long long i, j, n, m;
  cin >> n >> m;
  long long deg = 0;
  long long lm = -1;
  for (i = 1; i <= n; i++) {
    cin >> d[i];
    if (d[i] != -1)
      deg += d[i];
    else {
      d[i] = 0;
      lm = i;
    }
  }
  if (deg % 2 == 1 && lm == -1) {
    cout << "-1";
    return 0;
  }
  if (deg % 2) d[lm] = 1;
  for (i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    v[x].push_back(make_pair(y, i + 1));
    v[y].push_back(make_pair(x, i + 1));
  }
  dfs(1);
  cout << ans.size() << endl;
  for (auto x : ans) cout << x << endl;
  return 0;
}
