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];
unordered_set<int> bad;
map<pair<int, int>, int> ind;
set<int> ribs;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = (1); i < (n + 1); ++i) scanf("%d", &d[i]);
  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);
    deg[v]++;
    deg[u]++;
    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 ((int)g[i].size() % 2 != d[i]) {
        bad.insert(i);
      }
    }
  }
  while (!bad.empty()) {
    if ((int)ribs.size() == 0) {
      cout << -1;
      return 0;
    }
    int v = *bad.begin();
    bool ok = 0;
    for (auto u : g[v]) {
      if (bad.count(u)) {
        bad.erase(v);
        bad.erase(u);
        ribs.erase(ind[make_pair(v, u)]);
        deg[v]--;
        deg[u]--;
        ok = 1;
      }
    }
    if (!ok) {
      for (auto u : g[v]) {
        if (d[u] == -1) {
          bad.erase(v);
          ribs.erase(ind[make_pair(v, u)]);
          deg[v]--;
          deg[u]--;
          ok = 1;
        }
      }
    }
    if (!ok) {
      if ((int)g[v].size() == 0) {
        cout << -1;
        return 0;
      }
      int mx = 0, x = -1;
      for (auto u : g[v]) {
        if (deg[u] > mx) {
          mx = deg[u];
          x = u;
        }
      }
      bad.erase(v);
      bad.insert(x);
      ribs.erase(ind[make_pair(v, x)]);
      deg[v]--;
      deg[x]--;
    }
  }
  printf("%d\n", (int)ribs.size());
  for (auto x : ribs) printf("%d\n", x);
  return 0;
}
