#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
vector<pair<int, int> > g[N];
bool mark[N];
vector<int> ans;
int d[N], deg[N];
void dfs(int v) {
  mark[v] = true;
  for (int i = 0; i < g[v].size(); i++) {
    pair<int, int> x = g[v][i];
    int u = x.first, id = x.second;
    if (!mark[u]) {
      dfs(u);
      if (d[u] != -1 && deg[u] % 2 != d[u]) {
        ans.push_back(id);
        deg[u]++;
        deg[v]++;
      }
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  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 u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back({v, i});
    g[v].push_back({u, i});
  }
  dfs(root);
  if (d[root] != -1 && deg[root] % 2 != d[root]) return cout << -1, 0;
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    int x = ans[i];
    cout << x + 1 << " ";
  }
  return 0;
}
