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;
vector<pair<int, int> > e[300005];
int d[300005], mk[300005];
bool odd1, mr[300005];
queue<int> q;
pair<int, int> trace[300005];
set<int> p;
int bfs(int x, int u) {
  while (!q.empty()) q.pop();
  q.push(x);
  mr[x] = 0;
  trace[x] = {-1, -1};
  mk[x] = u;
  while (!q.empty()) {
    int t = q.front();
    q.pop();
    if ((d[t] == 1 && mr[t]) || (d[t] == -1 && odd1)) {
      mr[t] = 0;
      if (d[t] == -1 && odd1) odd1 = 0;
      return t;
    }
    for (int i = 0; i < (int)e[t].size(); ++i) {
      int x = e[t][i].first;
      if (mk[x] == u) continue;
      if (d[x] != 1 || (d[x] == 1 && mr[x])) {
        trace[x] = {t, e[t][i].second};
        mk[x] = u;
        q.push(x);
      }
    }
  }
  return -1;
}
void yo(int x) {
  if (trace[x].first != -1) yo(trace[x].first);
  if (trace[x].second != -1) p.insert(trace[x].second);
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &d[i]);
    odd1 ^= (d[i] & 1);
    if (d[i] & 1) mr[i] = 1;
  }
  for (int i = 1; i <= m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    e[x].push_back(make_pair(y, i));
    e[y].push_back(make_pair(x, i));
  }
  for (int i = 1; i <= n; ++i)
    if (mr[i]) {
      int tmp = bfs(i, i);
      if (tmp == -1) {
        puts("-1");
        return 0;
      }
      yo(tmp);
    }
  printf("%d\n", (int)p.size());
  for (int x : p) printf("%d ", x);
  return 0;
}
