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 = 3e5 + 10;
int n, m, col[maxn], node, f;
bool mark[maxn], e[maxn];
vector<pair<int, int> > adj[maxn];
stack<int> ans;
void dfs(int v, int edge) {
  ++mark[v];
  int cnt = 0;
  for (auto u : adj[v])
    if (!mark[u.first]) {
      dfs(u.first, u.second);
      cnt += e[u.first];
    }
  if (edge && cnt != col[v]) {
    ++e[v];
    ans.push(edge);
  }
  return;
}
int main() {
  cin >> n >> m;
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> col[i];
    if (col[i] == -1)
      f = i;
    else if (!node && col[i] == 1)
      ++cnt, node = i;
  }
  for (int i = 0, u, v; i < m; ++i) {
    cin >> v >> u;
    adj[v].push_back({u, i});
    adj[u].push_back({v, i});
  }
  if (!f && (cnt & 1)) {
    cout << -1 << '\n';
    return 0;
  }
  node = max(f, 1);
  dfs(node, 0);
  cout << ans.size() << '\n';
  while (!ans.empty()) {
    cout << ans.top() << '\n';
    ans.pop();
  }
  cout << '\n';
  return 0;
}
