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;
long long modpow(long long base, long long exponent, long long modulus) {
  if (base == 0 && exponent == 0) return 0;
  long long result = 1;
  while (exponent > 0) {
    if (exponent % 2 == 1) result = (result * base) % modulus;
    exponent = exponent >> 1;
    base = (base * base) % modulus;
  }
  return result;
}
int N, M;
vector<pair<int, int> > AdjList[200110];
int val[200110];
bool change[200110];
int k = 0;
int self[200110];
int who = -1, which = -1;
bool visited[200110];
bool removed[200110];
int dfs(int node) {
  visited[node] = true;
  int p = 0;
  if (change[node]) p = 1;
  for (int i = 0; i < AdjList[node].size(); i++) {
    int v = AdjList[node][i].first;
    int e = AdjList[node][i].second;
    if (!visited[v] and !removed[e]) {
      int u = dfs(v);
      p += u;
      p %= 2;
      if (u) {
        removed[e] = true;
      }
    }
  }
  return p;
}
inline void ReadInput(void) {
  scanf("%d", &N);
  scanf("%d", &M);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &val[i]);
  }
  for (int i = 1; i <= M; i++) {
    int a, b;
    scanf("%d", &a);
    scanf("%d", &b);
    removed[i] = false;
    if (a == b) {
      self[a] = i;
      who = a;
      AdjList[a].push_back(pair<int, int>(a, i));
    } else {
      AdjList[a].push_back(pair<int, int>(b, i));
      AdjList[b].push_back(pair<int, int>(a, i));
    }
  }
}
inline void solve(void) {
  for (int i = 1; i <= N; i++) {
    if (val[i] != -1 and (int) AdjList[i].size() % 2 != val[i]) {
      change[i] = true;
      k++;
    } else {
      change[i] = false;
    }
  }
  if (k % 2 == 1 and who == -1) {
    cout << -1 << endl;
    return;
  } else {
    if (k % 2 == 1) {
      removed[self[who]] = true;
      change[who] = true;
    }
    int p = dfs(1);
    assert(p == 0);
    int rr = 0;
    for (int i = 1; i <= M; i++) {
      if (!removed[i]) rr++;
    }
    cout << rr << endl;
    for (int i = 1; i <= M; i++) {
      if (!removed[i]) cout << i << " ";
    }
  }
}
inline void Refresh(void) {}
int main() {
  ReadInput();
  solve();
  return 0;
}
