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;
double PI = 4 * atan(1);
int n, m, d[300001], ans[300001], sum = 0;
int hei[300001];
vector<pair<int, int> > adj[300001];
vector<int> ra;
int par[300001];
void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i < n + 1; i++) {
    cin >> d[i];
    if (d[i] >= 0)
      sum += d[i];
    else
      ra.push_back(i);
  }
  for (int i : ra) d[i] = 0;
}
int getpar(int x) {
  if (par[par[x]] != par[x]) par[x] = getpar(par[x]);
  return par[x];
}
void unite(int a, int b, int c) {
  int a1 = getpar(a), b1 = getpar(b);
  if (a1 == b1) return;
  if (hei[a1] < hei[b1]) swap(a1, b1);
  par[b1] = a1;
  hei[a1] = max(hei[a1], hei[b1] + 1);
  adj[a].push_back({b, c});
  adj[b].push_back({a, c});
}
void dfs(int p, int no) {
  for (pair<int, int> a : adj[no])
    if (a.first != p) {
      dfs(no, a.first);
      if (d[a.first]) d[a.first] ^= 1, d[no] ^= 1, ans[a.second] = 1;
    }
}
int main() {
  init();
  if (sum % 2 == 1) {
    if (ra.size() == 0) {
      cout << -1;
      return 0;
    }
    d[ra[0]] = 1;
  }
  for (int i = 1; i < n + 1; i++) par[i] = i;
  for (int i = 1; i < m + 1; i++) {
    int a, b;
    cin >> a >> b;
    unite(a, b, i);
  }
  dfs(0, 1);
  int k = 0;
  for (int i = 1; i < m + 1; i++)
    if (ans[i]) k++;
  cout << k << "\n";
  for (int i = 1; i < m + 1; i++)
    if (ans[i]) cout << i << "\n";
}
