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>
#pragma optimize("O3")
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 7;
const int base = 2e5 + 1;
const long long MAX = 1e6;
const double EPS = 1e-9;
const double PI = acos(-1.);
const int MAXN = 3 * 1e5 + 147;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<vector<int> > g(MAXN);
int d[MAXN], deg[MAXN], bad[MAXN], was[MAXN];
map<pair<int, int>, int> ind;
set<int> ribs;
void dfs(int v) {
  was[v] = 1;
  int cnt = 0;
  for (auto u : g[v]) {
    if (!was[u]) {
      dfs(u);
      if (bad[u]) {
        cnt++;
        ribs.erase(ind[make_pair(v, u)]);
      }
    }
  }
  bad[v] ^= cnt % 2;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int sum = 0;
  for (int i = (1); i < (n + 1); ++i) {
    scanf("%d", &d[i]);
    if (d[i] > 0) sum++;
  }
  for (int i = (0); i < (m); ++i) {
    int v, u;
    scanf("%d%d", &v, &u);
    g[v].push_back(u);
    g[u].push_back(v);
    ind[make_pair(v, u)] = i + 1;
    ind[make_pair(u, v)] = i + 1;
    ribs.insert(i + 1);
  }
  for (int i = (1); i < (n + 1); ++i) {
    if (d[i] == -1) {
      if (sum % 2 == 1) {
        d[i] = 1;
        sum++;
      } else {
        d[i] = 0;
      }
    }
    if ((int)g[i].size() % 2 != d[i]) bad[i] = 1;
  }
  if (sum % 2 == 1) {
    cout << -1;
    return 0;
  }
  dfs(1);
  printf("%d\n", (int)ribs.size());
  for (auto x : ribs) printf("%d\n", x);
  return 0;
}
