#include <bits/stdc++.h>
using namespace std;
const int Maxn = 300 * 1000 + 10;
int n, m, d[Maxn], par[Maxn];
vector<int> adj[Maxn], ind[Maxn];
bool mark[Maxn], bad[Maxn], ans[Maxn], boo;
void dfs(int v) {
  mark[v] = true;
  if (boo) ans[par[v]] = !ans[par[v]];
  for (int i = 0; i < (int)adj[v].size(); i++) {
    if (!mark[adj[v][i]]) {
      par[adj[v][i]] = ind[v][i];
      dfs(adj[v][i]);
    }
  }
  if (bad[v]) boo = !boo;
  if (boo) ans[par[v]] = !ans[par[v]];
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  int mnf = -1;
  for (int i = 0; i < n; i++) {
    cin >> d[i];
    if (d[i] == -1) mnf = i;
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    adj[u].push_back(v), adj[v].push_back(u);
    ind[u].push_back(i + 1), ind[v].push_back(i + 1);
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (d[i] != -1 && (int)adj[i].size() % 2 != d[i]) {
      cnt++;
      bad[i] = true;
    }
  }
  if (cnt % 2 == 1 && mnf == -1) {
    cout << -1 << endl;
    return 0;
  } else {
    if (cnt % 2 == 1) bad[mnf] = true;
  }
  dfs(0);
  cnt = 0;
  for (int i = 1; i <= m; i++)
    if (!ans[i]) cnt++;
  cout << cnt << endl;
  for (int i = 1; i <= m; i++)
    if (!ans[i]) cout << i << " ";
  cout << endl;
  return 0;
}
