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;
struct he {
  int num, r, nx;
} a[300005 * 2];
int fir[300005], n, m, d[300005], l, r, flag, Flag, k, tmp, ans[300005],
    vis[300005], t[300005];
void add(int l, int r) {
  a[k].num = k / 2 + 1;
  a[k].r = r;
  a[k].nx = fir[l];
  fir[l] = k++;
}
void dfs(int x, int fa) {
  vis[x] = 1;
  if (fa != -1)
    if (d[x] == 1 || d[x] == -1) {
      flag = 1;
      d[x] = min(0, d[x]);
      tmp = x;
      vis[x] = 0;
      return;
    }
  for (int i = fir[x]; i != -1; i = a[i].nx)
    if (!vis[a[i].r] && t[i] != -1) {
      dfs(a[i].r, x);
      if (flag == 1) {
        if (fa == -1) {
          t[i] = t[i ^ 1] = -1;
        } else if (a[i].r == tmp && d[a[i].r] == 1) {
          t[i] = t[i ^ 1] = -1;
        }
        if (a[i].num != -1) ans[++ans[0]] = a[i].num;
        a[i].num = a[i ^ 1].num = -1;
        a[i].r = tmp;
        vis[x] = 0;
        return;
      }
    }
  vis[x] = 0;
}
int main() {
  memset(fir, -1, sizeof(fir));
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &d[i]);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &l, &r);
    add(l, r);
    add(r, l);
  }
  int t0 = 0;
  for (int i = 1; i <= n; i++)
    if (d[i] == 1) {
      t0++;
      flag = 0;
      dfs(i, -1);
      Flag |= flag;
    }
  if (Flag == 0 && t0)
    printf("-1\n");
  else {
    printf("%d\n", ans[0]);
    for (int i = 1; i <= ans[0]; i++) printf("%d ", ans[i]);
  }
}
