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 N = 3e5 + 5;
struct Edge {
  int u, v;
  inline int operator()(int x) { return u ^ v ^ x; }
};
Edge e[N];
vector<int> g[N];
int d[N], vis[N];
vector<int> res;
int dfs(int v) {
  int sum = 0;
  vis[v] = 1;
  for (int i : g[v])
    if (!vis[e[i](v)]) {
      int tmp = dfs(e[i](v));
      if (tmp) res.push_back(i);
      sum += tmp;
    }
  sum += d[v];
  return sum % 2;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &d[i]);
    if (d[i] != -1) cnt += d[i];
  }
  cnt %= 2;
  for (int i = 1; i <= n; ++i)
    if (d[i] == -1) {
      d[i] = cnt;
      cnt = 0;
    }
  if (cnt != 0) {
    printf("-1\n");
    return 0;
  }
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &e[i].u, &e[i].v);
    g[e[i].u].push_back(i);
    g[e[i].v].push_back(i);
  }
  dfs(1);
  sort(res.begin(), res.end());
  printf("%d\n", (int)res.size());
  for (int i : res) printf("%d\n", i);
}
