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 int MAXN = 300 * 1000 + 23;
int n, m, d[MAXN], hp = -1, c, sz[MAXN];
bitset<MAXN> mark, mirk, mork;
map<pair<int, int>, int> g;
vector<int> e, adj[MAXN];
int sfs(int v) {
  mirk[v] = true;
  sz[v] = (mark[v] == true ? 1 : 0);
  for (auto u : adj[v])
    if (!mirk[u]) sz[v] += sfs(u);
  return sz[v];
}
void dfs(int v) {
  mork[v] = true;
  for (auto u : adj[v])
    if (!mork[u]) {
      dfs(u);
      if (sz[u] & 1) e.push_back(g[{u, v}]);
    };
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> d[i];
    if (d[i] == 1) c++, mark[i] = true;
    if (d[i] == -1) hp = i;
  }
  if ((c & 1) && ~hp)
    mark[hp] = true;
  else if (c & 1)
    return cout << -1, 0;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    if (g[{u, v}] == 0)
      g[{u, v}] = g[{v, u}] = i + 1, adj[v].push_back(u), adj[u].push_back(v);
  }
  sfs(0);
  dfs(0);
  cout << e.size() << '\n';
  for (auto i : e) cout << i << ' ';
  return 0;
}
