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;
struct Edge {
  int u, v, id, used;
  int get(int x) { return u ^ v ^ x; }
} E[300010];
vector<int> adj[300010];
int aux[300010];
int deg[300010];
int nxt[300010];
int d[300010];
vector<int> ans;
int l = 0;
void dfs(int u) {
  if (d[u] == -1) return;
  if ((deg[u] & 1) == d[u]) return;
  if (nxt[u] == (int)adj[u].size()) return;
  while (E[nxt[u]].used) {
    nxt[u]++;
    if (nxt[u] == (int)adj[u].size()) return;
  }
  int v = E[nxt[u]].get(u);
  ans.push_back(E[nxt[u]].id);
  E[nxt[u]].used = 1;
  deg[u]++;
  deg[v]++;
  dfs(v);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  memset(aux, -1, sizeof aux);
  memset(deg, 0, sizeof deg);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> d[i];
  }
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    if (d[x] == -1 or d[y] == -1)
      aux[x] = i, aux[y] = i;
    else {
      E[l] = {x, y, i, 0};
      adj[x].push_back(l);
      adj[y].push_back(l);
      l++;
    }
  }
  for (int i = 0; i < n; ++i) {
    dfs(i);
  }
  for (int i = 0; i < n; ++i) {
    if (deg[i] != d[i] and d[i] != -1) {
      if (aux[i] != -1)
        ans.push_back(aux[i]);
      else
        return cout << -1 << endl, 0;
    }
  }
  cout << ans.size() << endl;
  for (int i : ans) cout << i + 1 << ' ';
  cout << endl;
}
