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;
bool vis[300001] = {false};
set<long long> ans;
long long d[300001];
set<long long> v[300001];
map<pair<long long, long long>, long long> m;
void dfs(long long i, long long p) {
  vis[i] = true;
  long long j;
  for (auto j : v[i]) {
    if (!vis[j]) dfs(j, i);
  }
  if (d[i]) {
    ans.insert(m[make_pair(i, p)]);
    d[p] = 1 - d[p];
  }
}
int main() {
  ios::sync_with_stdio(false);
  long long i, j, k, n, t, m2;
  cin >> n >> m2;
  for (i = 0; i < n; i++) cin >> d[i];
  for (i = 0; i < m2; i++) {
    cin >> j >> k;
    j--;
    k--;
    if (k < j) swap(j, k);
    m[make_pair(j, k)] = i;
    m[make_pair(k, j)] = i;
    v[j].insert(k);
    v[k].insert(j);
  }
  long long sum = 0;
  for (i = 0; i < n; i++) {
    if (d[i] == -1) break;
    sum += d[i];
  }
  if (i == n && sum % 2 == 1) {
    cout << -1;
    return 0;
  }
  for (i = 0; i < n; i++) {
    if (d[i] != -1) sum += d[i];
  }
  for (i = 0; i < n; i++) {
    if (d[i] == -1) {
      if (sum % 2 == 1)
        d[i] = 1, sum++;
      else
        d[i] = 0;
    }
  }
  dfs(0, -1);
  cout << ans.size() << endl;
  for (auto it : ans) cout << it + 1 << endl;
  return 0;
}
