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>
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const long long INF64 = (long long)2e18;
const double INFD = 1e30;
const double EPS = 1e-9;
const double PI = std::acos(-1);
const int MOD = 1e9 + 7;
template <typename T>
inline T read() {
  T X = 0, w = 0;
  char ch = 0;
  while (!isdigit(ch)) {
    w |= ch == '-';
    ch = getchar();
  }
  while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
  return w ? -X : X;
}
const int MAXN = 100005;
const int MAXV = (1 << 17) + 5;
int n, m, k;
int dr[4] = {0, 1, 0, -1};
int dc[4] = {-1, 0, 1, 0};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
int A[MAXN];
struct Edge {
  int v, id;
};
std::vector<int> G[MAXN];
std::vector<Edge> edges;
std::vector<int> ans;
int sz[MAXN];
bool vis[MAXN];
void dfs(int u, int p) {
  vis[u] = true;
  if (A[u] != 1) A[u] = 0;
  for (auto i : G[u]) {
    Edge& e = edges[i];
    if (e.v == p || vis[e.v]) continue;
    dfs(e.v, u);
    if (A[e.v] == 1) {
      A[u] ^= 1;
      ans.push_back(e.id);
    }
  }
}
void solve() {
  scanf("%d%d", &n, &m);
  int odd = 0;
  int lastV = -1;
  for (int i = 1; i <= n; i++) {
    A[i] = read<int>();
    odd += (A[i] == 1);
    if (A[i] == -1) lastV = i;
  }
  if (odd & 1 && lastV == -1) {
    printf("-1\n");
    return;
  }
  if (odd & 1) {
    A[lastV] = 1;
  }
  for (int i = 1; i <= m; i++) {
    int u = read<int>(), v = read<int>();
    G[u].push_back(edges.size());
    edges.push_back({v, i});
    G[v].push_back(edges.size());
    edges.push_back({u, i});
  }
  dfs(1, 1);
  printf("%d\n", ans.size());
  for (auto a : ans) {
    printf("%d\n", a);
  }
}
int main() {
  solve();
  return 0;
}
