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 MAX_N = 3e5 + 5;
struct Edge {
  int to, id;
};
struct Node {
  int dep, id;
  Node() {}
  Node(int dep_, int id_) : dep(dep_), id(id_) {}
  bool operator<(const Node &b) const { return dep > b.dep; }
};
int N, M;
int d[MAX_N];
vector<Edge> G[MAX_N];
int fa[MAX_N];
int en[MAX_N];
bool vis[MAX_N];
priority_queue<Node> que;
vector<int> ans;
bool inque[MAX_N];
int dep[MAX_N];
void addEdge(int a, int b, int id) {
  G[a].push_back((Edge){b, id});
  G[b].push_back((Edge){a, id});
}
void dfs(int v) {
  bool isLeaf = true;
  for (int i = 0; i < G[v].size(); ++i) {
    Edge &e = G[v][i];
    if (d[e.to] != -1 && !vis[e.to]) {
      vis[e.to] = true;
      fa[e.to] = v;
      dep[e.to] = dep[v] + 1;
      en[e.to] = e.id;
      dfs(e.to);
      isLeaf = false;
    }
  }
  if (isLeaf) {
    que.push(Node(dep[v], v));
    inque[v] = true;
  }
}
void solve() {
  while (!que.empty()) {
    Node v = que.top();
    que.pop();
    inque[v.id] = false;
    if (d[v.id] == 1) {
      d[fa[v.id]] ^= 1;
      if (!inque[fa[v.id]]) {
        que.push(Node(dep[fa[v.id]], fa[v.id]));
        inque[fa[v.id]] = true;
      }
      ans.push_back(en[v.id]);
    }
  }
  sort(ans.begin(), ans.end());
  printf("%u\n", ans.size());
  for (int i = 0; i < ans.size(); ++i) {
    printf("%d\n", ans[i]);
  }
}
int main() {
  cin >> N >> M;
  int sumD = 0, numn1 = 0, idxn1;
  for (int i = 0; i < N; ++i) {
    scanf("%d", &d[i]);
    if (d[i] != -1)
      sumD += d[i];
    else
      numn1++, idxn1 = i;
  }
  for (int i = 0; i < M; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    addEdge(a, b, i + 1);
  }
  if (numn1 == 0 && sumD % 2 == 1) {
    printf("-1\n");
    return 0;
  }
  if (sumD % 2 == 1) {
    d[idxn1] = 1;
  }
  for (int i = 0; i < N; ++i) {
    if (d[i] != -1) {
      fa[i] = -1;
      vis[i] = true;
      dep[i] = 0;
      dfs(i);
      break;
    }
  }
  solve();
  return 0;
}
