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;
signed main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> col(n);
  for (int i = 0; i < n; i++) cin >> col[i];
  vector<vector<pair<int, int>>> graph(n);
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    graph[x].emplace_back(y, i);
    graph[y].emplace_back(x, i);
  }
  int sum = 0;
  for (int i = 0; i < n; i++)
    if (col[i] > 0) sum ^= 1;
  for (int i = 0; i < n; i++)
    if (col[i] < 0)
      if (sum) {
        col[i] = 1;
        sum = 0;
      } else
        col[i] = 0;
  if (sum) {
    cout << "-1\n";
    return 0;
  }
  vector<int> subset;
  vector<bool> visited(n);
  function<bool(int)> dfs = [&](int v) {
    visited[v] = true;
    for (auto [ne, nei] : graph[v])
      if (!visited[ne]) {
        if (dfs(ne)) {
          subset.push_back(nei);
          col[v] ^= 1;
        }
      }
    return col[v];
  };
  dfs(0);
  cout << subset.size() << "\n";
  for (int e : subset) cout << e << "\n";
}
