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<int> Next[300005];
int d[300005];
int how[300005];
bool use[300005] = {0};
int a[300005];
int b[300005];
int main() {
  int N, M, i, t = 0, ok = 1, con = 0;
  scanf("%d %d", &N, &M);
  for (i = 1; i <= N; i++) {
    scanf("%d", &d[i]);
  }
  for (i = 1; i <= M; i++) {
    scanf("%d %d", &a[i], &b[i]);
    how[a[i]]++;
    how[b[i]]++;
  }
  for (i = 1; i <= M; i++) {
    if ((d[a[i]] == -1 || how[a[i]] % 2 != d[a[i]]) &&
        (d[b[i]] == -1 || how[b[i]] % 2 != d[b[i]])) {
      use[i] = 1;
      how[a[i]]--;
      how[b[i]]--;
    } else
      con++;
  }
  for (i = 1; i <= N; i++) {
    if (d[i] != -1 && d[i] != how[i] % 2) ok = 0;
  }
  if (ok) {
    printf("%d\n", con);
    for (i = 1; i <= M; i++)
      if (!use[i]) printf("%d\n", i);
  } else
    printf("-1\n");
  return 0;
}
