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;
bool dfs(vector<vector<pair<int, int>>> &G, int i, set<int> &ans,
         vector<int> &d, vector<int> &vis) {
  if (vis[i]++) return true;
  int degree = 0;
  for (auto each : G[i]) {
    if (!dfs(G, each.first, ans, d, vis)) {
      ++degree;
      ans.insert(each.second);
    }
  }
  return d[i] == -1 || degree % 2 == d[i];
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  int from, to;
  cin >> n >> m;
  vector<vector<pair<int, int>>> G(n + 1);
  vector<int> d(n + 1);
  for (int i = 1; i <= n; ++i) cin >> d[i];
  for (int i = 1; i <= m; ++i) {
    cin >> from >> to;
    G[from].push_back(make_pair(to, i));
    G[to].push_back(make_pair(from, i));
  }
  set<int> ans;
  vector<int> vis(n + 1);
  if (!dfs(G, 1, ans, d, vis)) return cout << -1, 0;
  cout << ans.size() << endl;
  for (int each : ans) cout << each << endl;
}
