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;
map<pair<int, int>, int> edge;
vector<int> d;
vector<vector<int>> v;
vector<bool> used;
vector<int> ans;
vector<int> cnt;
bool flag = 0;
void dfs(int u, int pr = -1) {
  used[u] = 1;
  for (int i = 0; i < v[u].size(); i++) {
    if (!used[v[u][i]]) {
      dfs(v[u][i], u);
    }
  }
  if (d[u] == -1) {
    return;
  }
  if (cnt[u] % 2 != d[u]) {
    if (pr == -1) {
      flag = 1;
    } else {
      cnt[u]++;
      cnt[pr]++;
      ans.push_back(edge[{u, pr}]);
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  v.resize(n);
  d.resize(n);
  used.resize(n);
  cnt.resize(n);
  int root = 0;
  for (int i = 0; i < n; i++) {
    cin >> d[i];
    if (d[i] == -1) {
      root = i;
    }
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    v[a - 1].push_back(b - 1);
    v[b - 1].push_back(a - 1);
    edge[{a - 1, b - 1}] = i + 1;
    edge[{b - 1, a - 1}] = i + 1;
  }
  dfs(root);
  if (flag) {
    cout << -1 << endl;
  } else {
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) {
      cout << ans[i] << ' ';
    }
    cout << endl;
  }
}
