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 P = 1e9 + 7;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long qpow(long long a, long long n) {
  long long r = 1 % P;
  for (a %= P; n; a = a * a % P, n >>= 1)
    if (n & 1) r = r * a % P;
  return r;
}
long long inv(long long x) { return x <= 1 ? 1 : inv(P % x) * (P - P / x) % P; }
const int N = 2e6 + 10;
int d[N], vis[N], v[N], n, m, cnt;
struct _ {
  int to, id;
};
vector<_> g[N];
void dfs(int x) {
  if (vis[x]) return;
  vis[x] = 1;
  for (_ e : g[x]) {
    dfs(e.to);
    if (d[e.to] == 1) v[e.id] ^= 1, d[e.to] ^= 1, d[x] ^= 1;
  }
}
int main() {
  scanf("%d%d", &n, &m);
  int rt = 1;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", d + i);
    if (d[i] == -1) rt = i;
  }
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back((_){v, i}), g[v].push_back((_){u, i});
  }
  dfs(rt);
  if (d[rt] == 1) return puts("-1"), 0;
  for (int i = 1; i <= m; ++i)
    if (v[i]) ++cnt;
  printf("%d\n", cnt);
  for (int i = 1; i <= m; ++i)
    if (v[i]) printf("%d ", i);
  putchar('\n');
}
