#include <bits/stdc++.h>
using namespace std;
map<char, int> m;
vector<int> v(3000005), depth(300005), d(300005), ans;
vector<int> g[300005], ind[300005];
int dfs(int n, int i) {
  v[n] = 1;
  int j;
  int temp = 0;
  for (j = 0; j < g[n].size(); j++) {
    if (!v[g[n][j]]) {
      temp = (temp + dfs(g[n][j], ind[n][j])) % 2;
    }
  }
  if (d[n] == 1) {
    temp = (temp + 1) % 2;
  }
  if (temp % 2) {
    ans.push_back(i);
  }
  return temp;
}
int main() {
  ios::sync_with_stdio(0);
  cout.tie(NULL);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  int i, flag = 0, onec = 0;
  for (i = 1; i <= n; i++) {
    cin >> d[i];
    if (d[i] == -1)
      flag = 1;
    else if (d[i])
      onec++;
  }
  for (i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
    ind[x].push_back(i + 1);
    ind[y].push_back(i + 1);
  }
  if (!flag && onec % 2) {
    cout << -1 << endl;
    return 0;
  } else if (onec % 2) {
    for (i = 1; i <= n; i++)
      if (d[i] == -1) {
        d[i] = 1;
        break;
      }
  }
  int temp = dfs(1, -1);
  sort(ans.begin(), ans.end());
  cout << ans.size() << endl;
  for (i = 0; i < ans.size(); ++i) {
    cout << ans[i] << ' ';
  }
  cout << endl;
}
