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 + 10;
int n, m;
vector<pair<int, int> > graf[N];
int d[N];
bool los[N];
bool bio[N];
vector<int> sol;
bool dfs(int node, int back_edge) {
  bio[node] = true;
  bool dodaj = los[node];
  for (auto y : graf[node]) {
    if (bio[y.first]) continue;
    dodaj ^= dfs(y.first, y.second);
  }
  if (dodaj) sol.push_back(back_edge);
  return dodaj;
}
int main() {
  scanf("%d %d", &n, &m);
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &d[i]);
    if (d[i] != -1) {
      sum += d[i];
      los[i] = (bool)d[i];
    } else
      los[i] = false;
  }
  for (int i = 1; i <= n; i++) {
    if (d[i] == -1 && sum % 2) {
      d[i] = 1;
      los[i] = true;
      sum++;
      break;
    }
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    graf[u].push_back(make_pair(v, i + 1));
    graf[v].push_back(make_pair(u, i + 1));
  }
  if (sum % 2) {
    printf("%d\n", -1);
    return 0;
  }
  dfs(1, -1);
  printf("%d\n", (int)sol.size());
  for (auto y : sol) printf("%d\n", y);
  return 0;
}
