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;
vector<int> a[300010];
int nd[300010], elr[1000010], nxt[300010], cnt, last, d[300010];
bool vis[300010];
map<int, int> e[300010];
void dfs(int x) {
  while (1) {
    ++nxt[x];
    while (nxt[x] < a[x].size()) {
      if (e[x][a[x][nxt[x]]]) break;
      ++nxt[x];
    }
    if (nxt[x] >= a[x].size()) {
      if (!vis[x]) {
        elr[cnt++] = x;
        if (d[x] == 1) {
          if (last != -1) {
            nd[cnt - 1] = 0;
            last = -1;
          } else {
            nd[cnt - 1] = 1;
            last = x;
          }
        }
      }
      vis[x] = 1;
      return;
    }
    e[x][a[x][nxt[x]]] = 0;
    e[a[x][nxt[x]]][x] = 0;
    dfs(a[x][nxt[x]]);
  }
}
int mp[4];
map<int, int> edg[300010];
int main() {
  int n, m, x, y, tmp;
  while (cin >> n >> m) {
    tmp = -1;
    cnt = 0;
    memset(nd, -1, sizeof nd);
    memset(nxt, -1, sizeof nxt);
    memset(vis, 0, sizeof vis);
    for (int i = 1; i <= n; ++i) {
      a[i].clear();
      scanf("%d", &d[i]);
      ++mp[d[i] + 1];
      if (d[i] == -1) tmp = i;
    }
    for (int i = 0; i < m; ++i) {
      scanf("%d%d", &x, &y);
      a[x].push_back(y);
      a[y].push_back(x);
      edg[x][y] = i + 1;
      edg[y][x] = i + 1;
      e[x][y] = 1;
      e[y][x] = 1;
    }
    if ((mp[2] % 2 == 1) && (mp[0]) == 0) {
      cout << -1 << endl;
      continue;
    }
    if (mp[2] % 2) {
      d[tmp] = 1;
    }
    last = -1;
    dfs(1);
    tmp = -1;
    vector<int> v;
    for (int i = 0; i < cnt; ++i) {
      if (nd[i] == 1)
        tmp = 1;
      else if (nd[i] == 0)
        tmp = 0;
      if (tmp == 1) {
        v.push_back(edg[elr[i]][elr[i + 1]]);
      }
    }
    cout << v.size() << endl;
    for (int i = 0; i < v.size(); ++i) {
      printf("%d\n", v[i]);
    }
  }
  return 0;
}
