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 d[300050];
bool vis[300050];
vector<int> rlt;
vector<pair<int, int> > con[300050];
int dfs(int u) {
  vis[u] = 1;
  int t = d[u];
  for (auto v : con[u])
    if (!vis[v.first] && dfs(v.first)) rlt.push_back(v.second), t ^= 1;
  return t;
}
int main() {
  int id;
  int n, m, sum = 0;
  cin >> n >> m;
  bool ff = 0;
  for (int i = 1; i <= n; i++) {
    cin >> d[i];
    if (d[i] == -1)
      ff = 1, d[i] = 0, id = i;
    else
      sum += d[i];
  }
  if (sum % 2 && !ff) return puts("-1");
  if (ff) d[id] = sum % 2;
  int u, v;
  for (int i = 1; i <= m; i++) {
    cin >> u >> v;
    con[u].push_back({v, i});
    con[v].push_back({u, i});
  }
  dfs(1);
  cout << rlt.size() << endl;
  for (int i : rlt) cout << i << endl;
  return 0;
}
