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 long long MAXN = 3e5 + 10;
struct edge {
  long long ver, nxt, num;
} e[MAXN * 2];
long long head[MAXN], tot;
void add(long long u, long long ver, long long num) {
  e[++tot].ver = ver;
  e[tot].num = num;
  e[tot].nxt = head[u];
  head[u] = tot;
}
long long d[MAXN], f[MAXN], odd = 0, fre = 0;
bool vis[MAXN] = {false};
map<pair<long long, long long>, long long> mp;
vector<long long> res;
void dfs1(long long u) {
  long long i;
  vis[u] = true;
  if (!(~d[u])) fre = u;
  if (d[u] == 1) odd++;
  for (i = head[u]; i; i = e[i].nxt) {
    long long v = e[i].ver;
    if (vis[v]) continue;
    f[v] = u;
    dfs1(v);
  }
  return;
}
void dfs2(long long u) {
  long long i;
  for (i = head[u]; i; i = e[i].nxt) {
    long long v = e[i].ver;
    if (f[v] != u) continue;
    dfs2(v);
    if (d[v]) {
      res.push_back(e[i].num);
      d[u] ^= 1;
    }
  }
  return;
}
int main() {
  long long n, m, i;
  scanf("%lld %lld", &n, &m);
  for (i = 1; i <= n; i++) scanf("%lld", &d[i]);
  for (i = 1; i <= m; i++) {
    long long u, v;
    scanf("%lld %lld", &u, &v);
    if (mp[make_pair(u, v)]) continue;
    mp[make_pair(u, v)] = 1ll;
    add(u, v, i);
    add(v, u, i);
  }
  dfs1(1);
  if (odd & 1) {
    if (!fre) {
      printf("-1");
      return 0;
    } else
      d[fre] = 1;
  }
  for (i = 1; i <= n; i++)
    if (!(~d[i])) d[i] = 0;
  dfs2(1);
  printf("%lld\n", res.size());
  for (i = 0; i < res.size(); i++) printf("%lld\n", res[i]);
  return 0;
}
