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 long long MAXN = 310000;
long long d[MAXN];
vector<pair<long long, long long> > g[MAXN];
vector<long long> ans;
bool visit[MAXN] = {0};
void dfs(long long v, long long p = -1) {
  visit[v] = 1;
  long long toUpRoad = 0;
  for (pair<long long, long long> A : g[v]) {
    long long u = A.first, roadIndex = A.second;
    if (u == p) toUpRoad = roadIndex;
    if (!visit[u]) {
      dfs(u, v);
    }
  }
  if (d[v] == 1) {
    d[v] = 0;
    ans.push_back(toUpRoad);
    d[p] ^= 1;
  }
}
int main() {
  long long u, v, n, m, sumdeg = 0;
  scanf("%lld%lld", &n, &m);
  for (long long i = 0; i < n; ++i)
    scanf("%lld", d + i), sumdeg += d[i] < 0 ? 0 : d[i];
  for (long long i = 0; i < m; ++i) {
    scanf("%lld%lld", &u, &v);
    --u, --v;
    g[u].emplace_back(v, i);
    g[v].emplace_back(u, i);
  }
  if (sumdeg % 2 == 0 || find(d, d + n, -1) != d + n) {
    if (sumdeg % 2 == 1) {
      for (long long i = 0, ok = 1; i < n; ++i)
        if (ok && d[i] == -1)
          ok = 0, d[i] = 1;
        else if (d[i] == -1)
          d[i] = 0;
    }
    dfs(0);
    printf("%lu\n", ans.size());
    for (long long i = 0; i < ans.size(); ++i)
      printf("%lld%c", ans[i] + 1, " \n"[i == ans.size() - 1]);
  } else
    puts("-1");
}
