#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 7;
struct edge {
  int v, x;
};
vector<edge> e[maxn], e2[maxn];
int n, m, ans, num;
int a[maxn], deg[maxn], f[maxn];
int flag = 0;
int f2[maxn];
void build(int x, int pre) {
  int i, j, len = e[x].size();
  for (i = 0; i < len; ++i) {
    edge t = e[x][i];
    int v = t.v;
    if (v == pre) continue;
    if (!f2[v]) {
      f2[v] = 1;
      e2[x].push_back(t);
      build(v, x);
    }
  }
}
void dfs(int x) {
  int i, j, k, len = e2[x].size();
  for (i = 0; i < len; ++i) {
    int v = e2[x][i].v;
    dfs(v);
    a[x] += a[v];
    if (a[v] == 1) f[e2[x][i].x] = 1;
  }
  a[x] %= 2;
}
int main() {
  int i, j, k, T;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (i = 1; i <= m; ++i) {
    int u, v;
    edge t;
    t.x = i;
    scanf("%d%d", &u, &v);
    t.v = v;
    e[u].push_back(t);
    t.v = u;
    e[v].push_back(t);
    deg[u]++;
    deg[v]++;
  }
  k = 1;
  for (i = 1; i <= n; ++i) {
    if (a[i] == -1) flag = 1, k = i;
    if (a[i] == -1 || deg[i] % 2 == a[i])
      a[i] = 0;
    else
      a[i] = 1, num++;
  }
  if (flag == 0 && num % 2 == 1) return 0 * printf("-1");
  f2[k] = 1;
  build(k, -1);
  dfs(k);
  vector<int> cho;
  for (i = 1; i <= m; ++i) {
    if (!f[i]) {
      ans++;
      cho.push_back(i);
    }
  }
  printf("%d\n", ans);
  for (i = 0; i < cho.size(); ++i) printf("%d ", cho[i]);
  return 0;
}
