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;
pair<int, int> ed[300005];
int ar[300005];
vector<int> aj[300005], adj[300005], vx;
map<pair<int, int>, int> mm;
int vis[300005];
vector<int> tree[1 << 20];
int tin[1 << 20], tout[1 << 20], pv[1 << 20], subsize[1 << 20];
int timer, par[1 << 20][22], dist[1 << 20], pr = -1, nu;
vector<pair<int, int> > ans;
vector<int> an;
void dfs(int v, int _depth) {
  dist[v] = _depth;
  int to;
  bool fl;
  for (int i = 0; i < tree[v].size(); i++) {
    to = tree[v][i];
    if (to == pv[v]) continue;
    pv[to] = v;
    dfs(to, _depth + 1);
    if (ar[v] == 1 && pr != -1) {
      pr = -1;
      ar[v] = 0;
      ;
    }
  }
  if (ar[v] == 1) {
    pr = v;
    ar[v] = 0;
    ;
  }
  if (pr != -1 && pv[v] > 0) vis[mm[make_pair(v, pv[v])]] ^= 1;
  if (ar[v] == 1 && pr != -1) {
    pr = -1;
    ar[v] = 0;
    ;
  }
}
bool upper(int a, int b) { return (tin[a] <= tin[b] && tout[a] >= tout[b]); }
int lca(int a, int b) {
  if (upper(a, b)) return a;
  if (upper(b, a)) return b;
  for (int i = 19; i >= 0; i--)
    if (!upper(par[a][i], b)) a = par[a][i];
  return par[a][0];
}
int go_up(int a, int b) {
  for (int i = 19; i >= 0; i--)
    if (!upper(par[a][i], b)) a = par[a][i];
  return a;
}
int distance(int a, int b, int c) { return dist[a] + dist[b] - 2 * dist[c]; }
queue<int> qu;
int main() {
  int n, m, u, v, x;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    scanf("%d", &ar[i + 1]);
    if (ar[i + 1] == 1) nu++;
  }
  if (nu % 2) {
    bool fl = 0;
    for (int i = 1; i < n + 1; i++)
      if (ar[i] == -1) {
        ar[i] = 1;
        ;
        fl = 1;
        break;
      }
    if (fl == 0) {
      cout << "-1\n";
      return 0;
    }
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &u);
    scanf("%d", &v);
    ed[i] = make_pair(u, v);
    mm[ed[i]] = i + 1;
    mm[make_pair(v, u)] = i + 1;
    aj[u].push_back(v);
    aj[v].push_back(u);
  }
  qu.push(1);
  vis[1] = 1;
  v = 1;
  while (v < n) {
    x = qu.front();
    qu.pop();
    for (auto it : aj[x])
      if (!vis[it]) {
        vis[it] = 1;
        v++;
        tree[x].push_back(it);
        tree[it].push_back(x);
        qu.push(it);
      }
  }
  memset(vis, 0, sizeof(vis));
  dfs(1, 0);
  for (int i = 0; i < m + 1; i++)
    if (vis[i] == 1) an.push_back(i);
  cout << an.size() << endl;
  for (auto it : an) cout << it << endl;
}
