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 N = 3e5 + 1;
const int M = 1e9 + 7;
const double eps = 1e-6;
int n, m;
int d[N];
vector<int> ans;
vector<pair<int, int> > g[N];
int vis[N];
void dfs(int u, int p, int id) {
  vis[u] = 1;
  for (auto i : g[u])
    if (!vis[i.first]) dfs(i.first, u, i.second);
  if (d[u]) {
    d[p] ^= 1;
    ans.push_back(id);
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  int dt = 0, f = 0;
  for (int i = (1); i <= (n); i++) {
    cin >> d[i];
    if (~d[i])
      dt += d[i];
    else
      f++;
  }
  if (dt > f) return cout << -1, 0;
  for (int i = 1; i <= n && dt; i++) {
    if (d[i] == -1) d[i] = 1, dt--;
  }
  for (int i = (1); i <= (m); i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back({v, i});
    g[v].push_back({u, i});
  }
  dfs(1, 0, 0);
  cout << ans.size() << endl;
  for (auto x : ans) cout << x << endl;
}
