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>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
const double eps = 1e-9;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 300000 + 10;
template <typename T>
T read(T &x) {
  int f = 0;
  register char c = getchar();
  while (c > '9' || c < '0') f |= (c == '-'), c = getchar();
  for (x = 0; c >= '0' && c <= '9'; c = getchar())
    x = (x << 3) + (x << 1) + (c ^ 48);
  if (f) x = -x;
  return x;
}
struct node {
  int u, v;
} edge[maxn];
int point[maxn], du[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  memset(du, 0, sizeof(du));
  for (int i = 1; i <= n; i++) {
    cin >> point[i];
  }
  for (int i = 1; i <= m; i++) {
    cin >> edge[i].u >> edge[i].v;
    du[edge[i].u]++;
    du[edge[i].v]++;
  }
  int ok = 0;
  for (int i = 1; i <= n; i++) {
    if (point[i] == -1 || point[i] == du[i] % 2) {
      ok = i;
      break;
    }
  }
  if (ok) {
    if (point[ok] == -1) {
      cout << "0" << endl;
    } else {
      cout << du[ok] << endl;
      for (int i = 1; i <= n; i++) {
        if (edge[i].u == ok || edge[i].v == ok) {
          cout << i << endl;
        }
      }
    }
  } else {
    cout << "-1" << endl;
  }
}
