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 ll = long long;
using ld = long double;
using namespace std;
const int MAXN = 2000001;
int d[MAXN];
bool w[MAXN];
vector<pair<int, int> > e[MAXN];
vector<int> ans;
int dfs(int v) {
  if (w[v]) return 0;
  w[v] = true;
  int sm = d[v];
  for (auto& ed : e[v]) {
    int dc = dfs(ed.first);
    if (dc & 1) ans.push_back(ed.second), sm++;
  }
  return sm;
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(20);
  int n, m;
  cin >> n >> m;
  int c1 = 0;
  int free = 0;
  for (int i = 1; i <= n; i++) {
    cin >> d[i];
    if (d[i] == -1) {
      free = i;
      d[i] = 0;
    }
    c1 += d[i];
  }
  if (c1 & 1) {
    if (free)
      d[free] = 1;
    else {
      cout << -1 << "\n";
      return 0;
    }
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    e[a].emplace_back(b, i + 1);
    e[b].emplace_back(a, i + 1);
  }
  memset(w, 0, sizeof(w));
  dfs(1);
  cout << ans.size() << "\n";
  for (auto v : ans) cout << v << " ";
  cout << "\n";
  return 0;
}
