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;
int n, m;
vector<pair<int, int> > g[300005];
int d[300005], ans = 0;
bool ise[300005] = {}, visited[300005] = {};
void dfs(int u, int par, int ind) {
  visited[u] = 1;
  for (int i = 0; i < g[u].size(); i++) {
    if (!visited[g[u][i].first]) {
      dfs(g[u][i].first, u, i);
    }
  }
  if (d[u] == 1) {
    d[par] = d[par] ^ 1;
    ise[g[par][ind].second] = 1;
    ans++;
  }
  return;
}
int main() {
  cin >> n >> m;
  int idm = -1, sd = 0;
  for (int i = 0; i < n; i++) {
    cin >> d[i];
    if (d[i] == -1) {
      idm = i;
      d[i] = 0;
    }
    sd += d[i];
  }
  if (sd & 1) {
    if (idm == -1) {
      cout << -1 << endl;
      return 0;
    }
    d[idm] = 1;
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    g[u].push_back({v, i});
    g[v].push_back({u, i});
  }
  dfs(0, -1, 0);
  cout << ans << endl;
  for (int i = 0; i < m; i++) {
    if (ise[i]) {
      cout << i + 1 << " ";
    }
  }
  cout << endl;
  return 0;
}
