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 nmax = 3e5 + 5;
int n, m, d[nmax];
vector<pair<int, int> > g[nmax];
vector<int> ans;
bool used[nmax];
int dfs(int x) {
  used[x] = 1;
  int crt = d[x];
  for (auto& yi : g[x]) {
    int y = yi.first;
    int i = yi.second;
    if (used[y]) continue;
    if (dfs(y)) {
      ans.push_back(i);
      crt ^= 1;
    }
  }
  return crt == 1 && d[x] != -1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> d[i];
  for (int i = 1, x, y; i <= m; i++) {
    cin >> x >> y;
    g[x].push_back({y, i});
    g[y].push_back({x, i});
  }
  int parity, cnt;
  parity = cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (d[i] == -1) {
      cnt++;
      continue;
    }
    parity ^= d[i];
  }
  if (!cnt && parity) {
    cout << -1 << '\n';
    return 0;
  }
  dfs(1);
  cout << ans.size() << '\n';
  for (int e : ans) {
    cout << e << '\n';
  }
  return 0;
}
