#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
long long modpow(long long a, long long n) {
  long long ret = 1;
  long long b = a;
  while (n) {
    if (n & 1) ret = (ret * b) % 3000000007ll;
    b = (b * b) % 3000000007ll;
    n >>= 1;
  }
  return (long long)ret;
}
vector<pair<int, int> > graph[300004];
int vis[300005];
vector<int> ans;
int arr[300005];
int dfs(int node) {
  if (vis[node]) return 0;
  vis[node] = 1;
  int par = arr[node];
  for (auto it : graph[node]) {
    if (dfs(it.first)) ans.push_back(it.second), par ^= 1;
  }
  return par;
}
int main() {
  int n, m;
  cin >> n >> m;
  int nodd = 0, nminus = 0;
  for (int i = 0; i < (int)n; i++) {
    cin >> arr[i + 1];
    if (arr[i + 1] == -1)
      nminus++;
    else if (arr[i + 1] % 2 == 1)
      nodd++;
  }
  if (nodd % 2 and !nminus) {
    cout << -1;
    exit(0);
  }
  int f = nodd % 2;
  for (int i = 0; i < (int)n; i++)
    if (arr[i + 1] == -1) arr[i + 1] = f, f = 0;
  for (int i = 0; i < (int)m; i++) {
    int a, b;
    cin >> a >> b;
    graph[a].push_back(make_pair(b, i + 1));
    graph[b].push_back(make_pair(a, i + 1));
  }
  dfs(1);
  sort(ans.begin(), ans.end());
  cout << ans.size() << endl;
  for (int u : ans) cout << u << " ";
  return 0;
}
