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 long long mod = 1000000007;
const int INF = 2123456789;
const double eps = 1e-7;
template <class T>
T gcd(T a, T b) {
  if (!b) return a;
  return gcd(b, a % b);
}
int d[300100];
int deg[300100];
set<int> ans;
vector<int> v;
vector<vector<pair<int, int> > > G(300100);
bool solve(int now) {
  for (int i = 0; i < (int)G[now].size(); i++) {
    if (deg[G[now][i].first] % 2 != d[G[now][i].first] &&
        d[G[now][i].first] != -1) {
      deg[now]--;
      deg[G[now][i].first]--;
      ans.insert(G[now][i].second);
      return 1;
    }
  }
  for (int i = 0; i < (int)G[now].size(); i++) {
    if (d[G[now][i].first] == -1) {
      deg[now]--;
      deg[G[now][i].first]--;
      ans.insert(G[now][i].second);
      return 1;
    }
  }
  return 0;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &d[i]);
  }
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(make_pair(v, i));
    G[v].push_back(make_pair(u, i));
    deg[v]++;
    deg[u]++;
  }
  for (int i = 1; i <= n; i++) {
    if (d[i] == -1 || deg[i] % 2 == d[i])
      continue;
    else if (!solve(i)) {
      cout << -1 << endl;
      return 0;
    }
  }
  for (int i = 1; i <= m; i++) {
    if (!ans.count(i)) v.push_back(i);
  }
  cout << v.size() << endl;
  for (int i = 0; i < (int)v.size(); i++) {
    printf("%d%c", v[i], i == (int)v.size() - 1 ? '\n' : ' ');
  }
  return 0;
}
