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;
const int INFS = 0x3fffffff;
const long long INFB = 0xfffffffffffffff;
struct Edge {
  int to, id;
  Edge() {}
  Edge(int _to, int _id) {
    to = _to;
    id = _id;
  }
};
bool visV[300005], visE[300005];
vector<vector<Edge> > v;
int d[300005];
int now[300005];
bool dfs(int id) {
  for (int i = 0; i < v[id].size(); i++) {
    if (visE[v[id][i].id]) continue;
    if (d[v[id][i].to] == -1) {
      visE[v[id][i].id] = true;
      return true;
    } else {
      now[v[id][i].to]++;
      if (now[v[id][i].to] % 2 == d[v[id][i].to]) {
        visE[v[id][i].id] = true;
        return true;
      } else {
        visE[v[id][i].id] = true;
        bool f = dfs(v[id][i].to);
        if (f) {
          return true;
        } else {
          visE[v[id][i].id] = false;
          now[v[id][i].to]--;
        }
      }
    }
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  while (cin >> n >> m) {
    for (int i = 1; i <= n; i++) {
      cin >> d[i];
    }
    vector<vector<Edge> >().swap(v);
    v.resize(n + 2);
    for (int i = 1; i <= m; i++) {
      int x, y;
      cin >> x >> y;
      v[x].push_back(Edge(y, i));
      v[y].push_back(Edge(x, i));
    }
    bool f = true;
    memset(now, 0, sizeof now);
    memset(visE, 0, sizeof visE);
    for (int i = 1; i <= n; i++) {
      if (now[i] % 2 == d[i] || d[i] == -1) continue;
      now[i]++;
      f = dfs(i);
      if (!f) break;
    }
    if (f) {
      int ans = 0;
      for (int i = 1; i <= m; i++) {
        if (visE[i]) ans++;
      }
      cout << ans << endl;
      for (int i = 1; i <= m; i++) {
        if (visE[i]) cout << i << endl;
      }
    } else
      cout << -1 << endl;
  }
}
