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;
using ii = pair<int, int>;
vector<int> e[300001];
map<ii, int> ecount;
vector<int> d;
vector<bool> visited;
vector<int> ans;
void dfs(int i) {
  visited[i] = true;
  for (auto& e : e[i]) {
    if (visited[e]) continue;
    dfs(e);
    if (d[e] == 1) {
      ans.push_back(ecount[make_pair(i, e)]);
      d[i] = (d[i] + 1) % 2;
    }
  }
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  d.resize(n + 1);
  visited.resize(n + 1);
  int dsum = 0;
  vector<int> minus;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &d[i]);
    if (d[i] == -1)
      minus.push_back(i);
    else
      dsum += d[i];
  }
  if (dsum % 2 == 1) {
    if (minus.empty()) {
      printf("-1");
      return 0;
    }
    d[minus[0]] = 1;
    for (int i = 1; i < minus.size(); i++) d[minus[i]] = 0;
  } else {
    for (int i = 0; i < minus.size(); i++) d[minus[i]] = 0;
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    e[a].push_back(b);
    e[b].push_back(a);
    ecount[make_pair(a, b)] = ecount[make_pair(b, a)] = i + 1;
  }
  dfs(1);
  printf("%d\n", ans.size());
  for (auto& a : ans) printf("%d\n", a);
  return 0;
}
