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 N = 3e5 + 5, inf = 1e9 + 7;
int n, k, p[N], c[N], f[N], z, vis[N];
map<pair<int, int>, int> m;
vector<int> adj[N];
int dfs(int id, int par) {
  vis[id] = 1;
  c[id] = 0;
  for (auto i : adj[id])
    if (!vis[i]) c[id] ^= dfs(i, id);
  if (c[id] != p[id]) f[m[pair<int, int>(id, par)]] = 1, z++;
  return (c[id] != p[id]);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int i, j, a, b, ans = 0, x = 0;
  cin >> n >> k;
  for (i = 1; i <= n; i++) {
    cin >> p[i];
    if (p[i] > 0) ans++;
    if (p[i] == -1) x = i;
  }
  if (ans & 1) {
    if (x == 0) return cout << -1, 0;
    p[x] = 1;
  }
  for (i = 1; i <= n; i++) p[i] = max(0, p[i]);
  for (i = 0; i < k; i++) {
    cin >> a >> b;
    adj[a].emplace_back(b);
    adj[b].emplace_back(a);
    m[pair<int, int>(a, b)] = m[pair<int, int>(b, a)] = i + 1;
  }
  dfs(1, 0);
  cout << z << "\n";
  for (i = 1; i <= k; i++)
    if (f[i]) cout << i << " ";
}
