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 = 300005;
int n, m;
int d[MAXN];
struct Edge {
  int to, id;
};
vector<Edge> G[MAXN];
int vis[MAXN] = {0};
vector<int> ans;
void solve(int u) {
  vis[u] = true;
  vector<Edge> ds;
  for (auto v : G[u]) {
    if (vis[v.to]) continue;
    solve(v.to);
    if (d[v.to] == 1) {
      d[u] ^= 1;
      ans.push_back(v.id);
    }
  }
}
int main() {
  cin >> n >> m;
  int odd = 0, flag = -1;
  for (int i = 0; i < n; i++) {
    cin >> d[i];
    if (d[i] == 1) odd++;
    if (d[i] == -1) d[flag = i] = 0;
  }
  if (odd & 1 && flag == -1)
    return puts("-1") & 0;
  else if (odd & 1 && flag != -1)
    d[flag] = 1;
  for (int i = 0, a, b; i < m; i++) {
    cin >> a >> b;
    --a, --b;
    G[a].push_back((Edge){b, 1 + i});
    G[b].push_back((Edge){a, 1 + i});
  }
  solve(0);
  cout << ans.size() << endl;
  for (auto it : ans) {
    cout << it << endl;
  }
  return 0;
}
