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 debug = 1;
const int N = 3.1e5;
int n, m, u, v, clr = 1, d[N], was[N], lab[N], pr[N];
vector<array<int, 2> > g[N];
array<int, 2> ed[N];
vector<int> ans;
void dfs(int v, int edp) {
  was[v] = 1;
  int cnt = 0;
  for (auto i : g[v]) {
    int u = i[0], ind = i[1];
    if (was[u]) continue;
    dfs(u, ind);
    cnt += lab[ind];
  }
  if (d[v] != -1 && cnt % 2 != d[v]) {
    if (edp == -1) {
      puts("-1");
      exit(0);
    }
    lab[edp] = 1;
    ans.push_back(edp);
  }
}
int main() {
  cin >> n >> m;
  int st = 1;
  for (int i = 1; i <= n; ++i) {
    cin >> d[i];
    if (d[i] == -1) st = i;
  }
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    ed[i] = {{u, v}};
    g[u].push_back({{v, i}});
    g[v].push_back({{u, i}});
  }
  dfs(st, -1);
  cout << ans.size() << '\n';
  for (int i : ans) cout << i + 1 << ' ';
  return 0;
}
