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 maxn = 1e6 + 10;
const int mod = 1e9 + 7;
int N, M;
int uf[maxn];
int find(int n) { return uf[n] = (uf[n] == n ? n : find(uf[n])); }
struct Edge {
  int to, id;
  Edge() {}
  Edge(int _to, int _id) : to(_to), id(_id) {}
};
vector<Edge> G[maxn];
vector<int> ans;
int d[maxn];
void dfs(int n, int pre) {
  int p = -1;
  for (auto e : G[n]) {
    if (e.to == pre) continue;
    dfs(e.to, n);
    if (d[e.to] == 1) {
      if (p != -1) {
        ans.push_back(pre);
        ans.push_back(e.id);
        p = -1;
      } else
        p = e.id;
    }
  }
  if (p != -1) {
    ans.push_back(p);
    d[n] ^= 1;
  }
}
int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 1; i <= N; i++) uf[i] = i;
  int p0 = 0, cnt = 0;
  for (int i = 1; i <= N; i++) {
    cin >> d[i];
    if (d[i] == -1) p0 = i;
    if (d[i] == 1) cnt++;
  }
  vector<pair<int, int> > E;
  for (int i = 1; i <= M; i++) {
    int u, v;
    cin >> u >> v;
    E.emplace_back(u, v);
  }
  auto solve = [&]() {
    for (int i = 0; i < E.size(); i++) {
      auto e = E[i];
      int fa = find(e.first);
      int fb = find(e.second);
      if (fa != fb) {
        uf[fa] = fb;
        G[e.first].emplace_back(e.second, i + 1);
        G[e.second].emplace_back(e.first, i + 1);
      }
    }
    dfs(1, -1);
    cout << ans.size() << "\n";
    for (int n : ans) cout << n << " ";
  };
  if (p0 == 0 && cnt & 1)
    cout << -1;
  else {
    for (int i = 1; i <= N; i++)
      if (d[i] == -1) d[i] = 0;
    if (cnt & 1) d[p0] = 1;
    solve();
  }
}
