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;
using ll = long long;
const int N = 3e5 + 10;
int n, m;
vector<pair<int, int>> G[N];
int va[N];
int pa[N];
bool arr[N];
bool isok(int x) {
  if (va[x] == -1) return true;
  return va[x] == pa[x] % 2;
}
bool dfs(int u) {
  if (isok(u)) return true;
  bool ok = false;
  for (auto v : G[u]) {
    if (!arr[v.second]) continue;
    if (!isok(v.first)) {
      arr[v.second] = 0;
      pa[u]--;
      pa[v.first]--;
      ok = true;
      break;
    }
  }
  if (ok) return true;
  for (auto v : G[u]) {
    if (!arr[v.second]) continue;
    if (va[v.first] == -1) {
      arr[v.second] = 0;
      pa[u]--;
      pa[v.first]--;
      ok = true;
      break;
    }
  }
  if (ok) return true;
  for (auto v : G[u]) {
    if (!arr[v.second]) continue;
    arr[v.second] = 0;
    pa[u]--;
    pa[v.first]--;
    if (dfs(v.first)) {
      ok = true;
      break;
    }
    arr[v.second] = 1;
    pa[u]++;
    pa[v.first]++;
  }
  return ok;
}
void solve() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> va[i];
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    G[a].emplace_back(b, i + 1);
    G[b].emplace_back(a, i + 1);
    pa[a]++;
    pa[b]++;
  }
  memset(arr, 1, sizeof arr);
  for (int i = 1; i <= n; i++) {
    if (!isok(i)) {
      if (!dfs(i)) {
        cout << -1 << endl;
        return;
      }
    }
  }
  vector<int> ans;
  for (int i = 1; i <= m; i++)
    if (arr[i]) ans.push_back(i);
  cout << ans.size() << endl;
  for (auto v : ans) cout << v << ' ';
  cout << endl;
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
}
