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 v, next;
  bool exist;
};
int n, m, d[300002], point[300002], x, y, ee;
edge e[600002];
bool v[300002];
vector<int> a;
void addEdge(int u, int v) {
  e[++ee].v = v;
  e[ee].next = point[u];
  point[u] = ee;
}
void makeTree(int u) {
  v[u] = true;
  for (int i = point[u]; i; i = e[i].next)
    if (!v[e[i].v]) {
      makeTree(e[i].v);
      if (d[e[i].v] == 1) {
        if (d[u] != -1) {
          d[u] = 1 - d[u];
        }
        a.push_back((i + 1) / 2);
      }
    }
}
int main() {
  int flag = 0, sum = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> d[i];
    if (d[i] == -1) flag = i;
    sum += d[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    addEdge(x, y);
    addEdge(y, x);
  }
  if (flag == 0 && (sum & 1)) {
    cout << -1 << endl;
  } else {
    if (flag == 0) flag = 1;
    makeTree(flag);
    cout << a.size() << endl;
    for (int i = 0; i < a.size(); i++) cout << a[i] << endl;
  }
}
