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 const N = 3e5 + 5;
vector<pair<int, int> > a[N];
int n, d[N], used[N], ok[N], m, Sum;
vector<int> ans;
void DFS(int u) {
  ok[u] = 1;
  for (int i = 0; i < a[u].size(); i++) {
    int v = a[u][i].first;
    int id = a[u][i].second;
    if (ok[v]) continue;
    DFS(v);
    if (d[v] == 1) {
      d[v] ^= 1;
      d[u] ^= 1;
      used[id] = 1;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> d[i];
  int pos = 0, u, v;
  for (int i = 1; i <= n; i++) {
    if (d[i] != -1)
      Sum += d[i];
    else {
      pos = i;
    }
  }
  Sum &= 1;
  if (pos == 0 && Sum) {
    cout << -1;
    return 0;
  }
  for (int i = 1; i <= n; i++)
    if (d[i] == -1 && i != pos) d[i] = 0;
  d[pos] = Sum;
  for (int i = 1; i <= m; i++) {
    cin >> u >> v;
    a[u].push_back(make_pair(v, i));
    a[v].push_back(make_pair(u, i));
  }
  DFS(1);
  for (int i = 1; i <= m; i++) {
    if (used[i]) ans.push_back(i);
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << endl;
}
