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 N = 1e6 + 10;
const int M = 2e6 + 10;
const int inf = 0x3f3f3f3f;
const long long mod = 998244353;
int h[N], ne[N], e[N], idx;
int d[N];
int st[N];
int id[N], sz[N];
vector<int> ans;
void add(int a, int b) { e[idx] = b, ne[idx] = h[a], h[a] = idx++; }
void dfs(int u, int k) {
  st[u] = 1;
  int i;
  sz[u] = (d[u] % 2);
  for (i = h[u]; i != -1; i = ne[i]) {
    int j = e[i];
    if (st[j]) continue;
    dfs(j, i);
    sz[u] += sz[j];
  }
  if (sz[u] % 2) {
    ans.push_back((k + 1) / 2);
  }
}
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int i;
  int sum = 0;
  int sign = 0;
  memset(h, -1, sizeof h);
  for (i = 1; i <= n; i++) {
    cin >> d[i];
    if (d[i] == -1)
      sign = 1;
    else
      sum += d[i];
  }
  if (!sign && (sum % 2)) {
    cout << -1 << endl;
    return 0;
  }
  if (sum % 2) {
    for (i = 1; i <= n; i++) {
      if (!sign) {
        if (d[i] == -1) d[i] = 0;
      } else {
        if (d[i] == -1) {
          d[i] = 1;
          sign = 0;
        }
      }
    }
  } else {
    for (i = 1; i <= n; i++) {
      if (d[i] == -1) d[i] = 0;
    }
  }
  while (m--) {
    int a, b;
    cin >> a >> b;
    add(a, b);
    add(b, a);
  }
  dfs(1, -1);
  sort(ans.begin(), ans.end());
  cout << (int)ans.size() << endl;
  for (auto x : ans) {
    cout << x + 1 << endl;
  }
  return 0;
}
