#include <bits/stdc++.h>
using namespace std;
int64_t n, m;
vector<int64_t> d;
vector<vector<int64_t> > v;
vector<int64_t> ans;
map<int64_t, int64_t> M;
int64_t gt(int64_t i, int64_t j) { return i * 1e9 + j; }
void rec(int64_t t, int64_t lst, vector<char> &ch) {
  if (ch[t]) return;
  ch[t] = true;
  for (int64_t i = 0; i < v[t].size(); ++i) {
    rec(v[t][i], t, ch);
  }
  if ((d[t] % 2) && lst != -1) {
    ans.push_back(M[gt(t, lst)]);
    d[lst]++;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  d.resize(n);
  v.resize(n);
  int64_t sm = 0;
  for (int64_t i = 0; i < n; ++i) {
    cin >> d[i];
    if (d[i] != -1) sm += d[i];
  }
  for (int64_t i = 0; i < n; ++i) {
    if (d[i] == -1) {
      if (sm % 2) {
        d[i] = 1;
        sm = 0;
      } else
        d[i] = 0;
    }
  }
  if (sm % 2) {
    cout << -1;
    return 0;
  }
  for (int64_t i = 0; i < m; ++i) {
    int64_t a, b;
    cin >> a >> b;
    --a;
    --b;
    v[a].push_back(b);
    v[b].push_back(a);
    M[gt(a, b)] = i;
    M[gt(b, a)] = i;
  }
  vector<char> ch(n, false);
  rec(0, -1, ch);
  cout << ans.size() << endl;
  for (int64_t i = 0; i < ans.size(); ++i) cout << ans[i] + 1 << ' ';
}
