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 MAXN = 3e5 + 1, INF = 1e9, MOD = 1e9 + 7;
int n, m, sum, d[MAXN], b;
vector<int> G[MAXN], ans;
map<pair<int, int>, int> pos;
bool mark[MAXN];
void dfs(int u = 1, int p = 0) {
  mark[u] = 1;
  for (int i = 0; i < G[u].size(); ++i) {
    int v = G[u][i];
    if (!mark[v]) dfs(v, u);
  }
  if (d[u]) {
    d[u] ^= 1;
    d[p] ^= 1;
    ans.push_back(pos[pair<int, int>(u, p)]);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> d[i];
    if (d[i] >= 0) {
      sum += d[i];
    } else {
      d[b] = 0;
      b = i;
    }
  }
  if (sum % 2 == 0) {
    d[b] = 0;
  } else {
    if (b == 0)
      return cout << -1 << endl, 0;
    else
      d[b] = 1;
  }
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
    pos[pair<int, int>(a, b)] = i + 1;
    pos[pair<int, int>(b, a)] = i + 1;
  }
  dfs();
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); ++i) {
    cout << ans[i] << endl;
  }
  return 0;
}
