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 mod = 1000000007;
const int maxn = 3e5 + 5;
int n, m;
int d[maxn];
vector<pair<int, int> > g[maxn];
vector<int> ans;
bool vis[maxn];
bool dfs(int x) {
  vis[x] = 1;
  bool res = d[x];
  for (pair<int, int> i : g[x]) {
    if (vis[i.first]) continue;
    if (dfs(i.first)) {
      ans.push_back(i.second);
      res ^= 1;
    }
  }
  if (d[x] == -1) res = 0;
  return res;
}
int main() {
  cin >> n >> m;
  int b = -1, ok = 0;
  for (int i = 1; i <= n; i++) {
    cin >> d[i];
    if (d[i] == -1)
      b = i;
    else
      ok ^= d[i];
  }
  for (int u, v, i = 1; i <= m; i++) {
    cin >> u >> v;
    g[u].push_back({v, i});
    g[v].push_back({u, i});
  }
  if (b == -1 && ok & 1) {
    printf("-1\n");
    return 0;
  }
  if (b == -1) b = 1;
  dfs(b);
  sort(ans.begin(), ans.end());
  printf("%d\n", ans.size());
  for (int i : ans) {
    printf("%d ", i);
  }
  printf("\n");
  return 0;
}
