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;
const int MOD = (int)1e9 + 7;
const int N = 300005;
const double PI = 4 * atan(1);
const double eps = 1e-7;
const long long oo = 1e10;
const int K = 26;
int n, m;
int d[N];
vector<pair<int, int> > adj[N];
int deg[N];
set<int> ss;
bool vis[N];
void dfs(int src) {
  if (vis[src]) return;
  vis[src] = 1;
  for (auto t : adj[src]) {
    if (vis[t.first]) continue;
    dfs(t.first);
    if (d[t.first] == -1) continue;
    if (deg[t.first] % 2 != d[t.first]) {
      deg[src]++;
      deg[t.first]++;
      ss.insert(t.second);
    }
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> d[i];
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    adj[u].push_back({v, i});
    adj[v].push_back({u, i});
  }
  int beg = 0;
  for (int i = 0; i < n; i++) {
    if (d[i] == -1) {
      beg = i;
      break;
    }
  }
  dfs(beg);
  for (int i = 0; i < n; i++) {
    if (d[i] == -1) continue;
    if (d[i] != (deg[i] % 2)) {
      cout << -1;
      return 0;
    }
  }
  cout << ss.size() << endl;
  for (auto t : ss) {
    cout << t + 1 << "\n";
  }
  return 0;
}
