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 MAXN = 3 * 112345;
vector<int> grafo[MAXN], id[MAXN];
int v[MAXN], marc[MAXN];
vector<int> rs;
int dfs(int a) {
  marc[a] = 1;
  int resp = v[a];
  if (v[a] == -1) resp = 0;
  for (int i = 0; i < grafo[a].size(); i++) {
    int viz = grafo[a][i], k = id[a][i];
    if (marc[viz] == 1) continue;
    int l = dfs(viz);
    resp += l;
    if (l == 1) rs.push_back(k);
  }
  return resp % 2;
}
int main() {
  int n, m, x = -1;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &v[i]);
    if (v[i] == -1) x = i;
  }
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    grafo[a].push_back(b);
    grafo[b].push_back(a);
    id[a].push_back(i);
    id[b].push_back(i);
  }
  if (x == -1) x = 1;
  if (dfs(x) % 2 == 0 || v[x] == -1) {
    printf("%d\n", rs.size());
    sort(rs.begin(), rs.end());
    for (int i = 0; i < rs.size(); i++) printf("%d\n", rs[i]);
  } else
    printf("-1\n");
}
