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;
const int MAX_M = 3e5;
int n, m;
int d[MAX_N + 1];
bool visit[MAX_N + 1];
vector<pair<int, int> > adj[MAX_N + 1];
vector<int> res;
void dfs(int u) {
  visit[u] = 1;
  for (auto& t : adj[u]) {
    int v = t.first;
    int idx = t.second;
    if (visit[v]) continue;
    dfs(v);
    if (d[v]) {
      d[u] ^= 1;
      d[v] ^= 1;
      res.push_back(idx);
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  int ones = 0, negs = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", d + i);
    ones += d[i] == 1;
    negs += d[i] < 0;
  }
  int flag = 0;
  if (ones & 1) {
    if (!negs) {
      puts("-1");
      return 0;
    } else
      flag = 1;
  }
  for (int i = 1; i <= n; ++i)
    if (d[i] < 0) {
      if (flag)
        d[i] = 1, flag = 0;
      else
        d[i] = 0;
    }
  for (int i = 1, a, b; i <= m; ++i) {
    scanf("%d%d", &a, &b);
    adj[a].push_back({b, i});
    adj[b].push_back({a, i});
  }
  fill(visit + 1, visit + n + 1, false);
  dfs(1);
  printf("%d\n", (int)res.size());
  for (int i : res) printf("%d ", i);
  return 0;
}
