#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
int n, m;
bool used[N];
int d[N];
vector<pair<int, int> > g[N];
vector<int> answer;
bool dfs(int v) {
  if (d[v] == -1) d[v] = 0;
  used[v] = true;
  for (pair<int, int> e : g[v]) {
    if (used[e.first]) continue;
    if (dfs(e.first)) {
      d[v] ^= 1;
      answer.push_back(e.second);
    }
  }
  return d[v];
}
void solve() {
  scanf("%d%d", &n, &m);
  int cntOne = 0;
  bool existMinus = false;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &d[i]);
    existMinus |= d[i] == -1;
    cntOne += d[i] == 1;
  }
  for (int i = 1, a, b; i <= m; ++i) {
    scanf("%d%d", &a, &b);
    --a, --b;
    g[a].push_back({b, i});
    g[b].push_back({a, i});
  }
  if (!existMinus && (cntOne % 2 == 1)) {
    puts("-1");
    return;
  }
  for (int i = 0; i < n && (cntOne % 2 == 1); ++i) {
    if (d[i] == -1) {
      d[i] = 1;
      break;
    }
  }
  dfs(0);
  printf("%d\n", (int)answer.size());
  for (int id : answer) {
    printf("%d ", id);
  }
}
int main() {
  solve();
  return 0;
}
