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;
int n, m;
int n1, n2;
int v[300010];
int grau[300010];
int specialEdge[300010];
bool marc[300010];
vector<int> ans;
vector<int> grafo[300010];
vector<int> indEdge[300010];
vector<pair<int, int> > edges;
void DFS(int cur) {
  marc[cur] = true;
  for (int i = 0; i < grafo[cur].size(); i++) {
    int prox = grafo[cur][i];
    int ind = indEdge[cur][i];
    if (marc[prox]) continue;
    DFS(prox);
    if (v[prox] != -1 && grau[prox] % 2 != v[prox]) {
      grau[prox]++;
      grau[cur]++;
      ans.push_back(ind);
    }
  }
}
int main() {
  scanf("%d %d", &n, &m);
  edges.push_back({0, 0});
  for (int i = 1; i <= n; i++) scanf("%d", &v[i]);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &n1, &n2);
    grafo[n1].push_back(n2);
    grafo[n2].push_back(n1);
    indEdge[n1].push_back(i);
    indEdge[n2].push_back(i);
    if (v[n1] > v[n2]) swap(n1, n2);
    if (v[n1] == -1) specialEdge[n2] = i;
    edges.push_back({n1, n2});
  }
  DFS(1);
  for (int i = 1; i <= n; i++) {
    if (v[i] == -1 || grau[i] % 2 == v[i]) continue;
    if (specialEdge[i] == 0) {
      printf("-1\n");
      return 0;
    } else
      ans.push_back(specialEdge[i]);
  }
  printf("%d\n", (int)ans.size());
  for (int i = 0; i < ans.size(); i++) printf("%d\n", ans[i]);
}
