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 = 1000 * 1000 + 10;
vector<pair<int, int> > vec[N];
vector<int> ans;
int a[N];
bool mark[N], ed[N];
void dfs(int v, int e) {
  mark[v] = true;
  int t = 0;
  for (auto u : vec[v])
    if (!mark[u.first]) {
      dfs(u.first, u.second);
      t += ed[u.first];
    }
  t %= 2;
  if (e != -1 && t != a[v]) {
    ans.push_back(e);
    ed[v] = true;
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  int v = -1, sm = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == -1) v = i;
    sm += a[i];
  }
  for (int i = 0; i < m; i++) {
    int c, b;
    cin >> b >> c;
    b--, c--;
    vec[b].push_back({c, i});
    vec[c].push_back({b, i});
  }
  if (v == -1 && sm % 2 != 0) {
    cout << -1 << endl;
    return 0;
  }
  v = max(v, 0);
  dfs(v, -1);
  cout << (int)ans.size() << endl;
  for (int i = 0; i < (int)ans.size(); i++) cout << ans[i] + 1 << endl;
  return 0;
}
