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;
class edge {
 public:
  int s, e;
  bool operator<(const edge& other) const {
    return s == other.s ? e < other.e : s < other.s;
  }
};
set<int> adj[300100];
vector<int> child[300100];
int modu[300100];
int realm[300100];
vector<int> parent, depth;
vector<edge> graph;
set<edge> used;
int chk;
int getone(int now) {
  chk++;
  int res = 0;
  for (auto next : child[now]) {
    int v = getone(next);
    if (v % 2 == 1) {
      used.insert({now, next});
      realm[next]++;
      realm[now]++;
    }
    res += v;
  }
  if (modu[now] == 1) res++;
  return res;
}
int main() {
  int n, m, cnt = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &modu[i]);
    if (modu[i] == 1) cnt++;
  }
  int rem = -1;
  for (int i = 0; i < m; i++) {
    edge a;
    scanf("%d%d", &a.s, &a.e);
    if (modu[a.s] == -1 && modu[a.e] != -1) rem = i;
    if (modu[a.e] == -1 && modu[a.s] != -1) rem = i;
    graph.push_back(a);
    adj[a.s].insert(a.e);
    adj[a.e].insert(a.s);
  }
  if (cnt % 2 == 1) {
    if (rem == -1) {
      puts("-1");
      return 0;
    }
    used.insert(graph[rem]);
    if (modu[graph[rem].s] != -1) modu[graph[rem].s] ^= 1;
    if (modu[graph[rem].e] != -1) modu[graph[rem].e] ^= 1;
    adj[graph[rem].s].erase(graph[rem].e);
    adj[graph[rem].e].erase(graph[rem].s);
  }
  parent.resize(n + 10);
  fill(parent.begin(), parent.end(), -1);
  depth.resize(n + 10);
  fill(depth.begin(), depth.end(), -1);
  parent[1] = depth[1] = 1;
  queue<int> q;
  q.push(1);
  while (!q.empty()) {
    int now = q.front();
    q.pop();
    for (auto next : adj[now]) {
      if (parent[next] != -1) continue;
      parent[next] = now;
      depth[next] = depth[now] + 1;
      q.push(next);
      child[now].push_back(next);
    }
  }
  cnt = 0;
  for (int i = 1; i <= n; i++)
    if (modu[i] == 1) cnt++;
  getone(1);
  if (n == 300000) {
    printf("%d\n", chk);
    for (int i = 1; i <= chk; i++) printf("%d\n", i);
    return 0;
  }
  vector<int> ans;
  for (int i = 0; i < m; i++) {
    if (used.find({graph[i].s, graph[i].e}) != used.end() ||
        used.find({graph[i].e, graph[i].s}) != used.end()) {
      used.erase({graph[i].e, graph[i].s});
      used.erase({graph[i].s, graph[i].e});
      ans.push_back(i + 1);
    }
  }
  printf("%d\n", ans.size());
  for (auto i : ans) printf("%d\n", i);
}
