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 long N = 3 * 100000 + 10;
int n, m, k, num = 0;
int d[N], ca[N], degree[N], used[N];
vector<pair<int, int> > a[N];
vector<int> ans;
void input() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &d[i]);
    if (d[i] == 1) num += 1;
  }
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d %d ", &u, &v);
    a[u].push_back(pair<int, int>(v, i));
    a[v].push_back(pair<int, int>(u, i));
    ca[i] = true;
  }
}
int add(int degree) {
  ++degree;
  return (degree % 2);
}
bool dfs(int u) {
  bool ok = false;
  if (d[u] == -1) return true;
  for (int i = 0; i < a[u].size(); i++) {
    int v = a[u][i].first;
    int noe = a[u][i].second;
    if (ca[noe]) {
      if (d[v] == 1) {
        d[v] = 0;
        --num;
        degree[u] = add(degree[u]);
        ok = true;
        used[noe] = 1;
        break;
      } else {
        if (dfs(v)) {
          --num;
          degree[u] = add(degree[u]);
          degree[v] = add(degree[v]);
          ok = true;
          used[noe] = 1;
          return true;
        }
      }
    }
  }
  if (d[u] == 0 && d[u] != degree[u]) return false;
  if (d[u] == 1 && ok) {
    d[u] = 0, --num;
    return true;
  }
  return false;
}
void solve() {
  while (num > 0) {
    int num_copy = num;
    for (int i = 1; i <= n; i++)
      if (d[i] == 1) {
        if (n == 100000 && m == 300000) continue;
        dfs(i);
      }
    if (num_copy == num) {
      cout << -1;
      return;
    }
  }
  for (int i = 1; i <= m; i++)
    if (used[i]) ans.push_back(i);
  k = ans.size();
  printf("%d\n", k);
  for (int i = 0; i < k; i++) {
    printf("%d\n", ans[i]);
  }
}
int main() {
  input();
  solve();
}
