#include <bits/stdc++.h>
struct link {
  link *nxt;
  int p, id;
};
const int N = 300000 + 10;
int n, m, d[N];
link poool[N << 1], *pool = poool, *head[N];
std::vector<int> ans;
inline void connect(int u, int v, int id) {
  pool->p = v, pool->id = id, pool->nxt = head[u], head[u] = pool++;
}
int dfs(int p, int id) {
  static bool vis[N];
  vis[p] = true;
  int cnt = d[p] == 1;
  for (link *e = head[p]; e; e = e->nxt)
    if (!vis[e->p]) cnt += dfs(e->p, e->id);
  if (cnt & 1) ans.push_back(id);
  return cnt & 1;
}
int main(void) {
  scanf("%d %d", &n, &m);
  int neg1 = 0, cnt;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", d + i);
    if (d[i] == -1)
      neg1 = i;
    else if (d[i] & 1)
      cnt += 1;
  }
  if (neg1 == 0 && (cnt & 1))
    return puts("-1"), 0;
  else if (cnt & 1)
    d[neg1] = 1;
  for (int i = 1, u, v; i <= m; ++i)
    scanf("%d %d", &u, &v), connect(u, v, i), connect(v, u, i);
  dfs(1, 0);
  printf("%d\n", ans.size());
  for (auto i : ans) printf("%d ", i);
}
