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 = 3 * 1000 * 100 + 10;
int n, m, a[N], e, cnt[N], parent[N];
vector<pair<int, int> > adj[N];
bool bad[N], mark[N], f;
void readInput() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    b--;
    adj[a].push_back(make_pair(b, i));
    adj[b].push_back(make_pair(a, i));
  }
  return;
}
void DFS(int v) {
  mark[v] = true;
  if (f) {
    cnt[adj[v][parent[v]].second]++;
    cnt[adj[v][parent[v]].second] %= 2;
  }
  for (int i = 0; i < (int)adj[v].size(); i++) {
    int u = adj[v][i].first, edge = adj[v][i].second;
    if (!mark[u]) {
      parent[u] = edge;
      DFS(u);
    }
  }
  if (bad[v]) {
    if (e == 0) {
      e = 1;
      f = true;
    } else {
      e = 0;
      f = false;
    }
  }
  if (f) {
    cnt[adj[v][parent[v]].second]++;
    cnt[adj[v][parent[v]].second] %= 2;
  }
  return;
}
int main() {
  readInput();
  int c = 0, p = -1;
  for (int i = 0; i < n; i++) {
    if ((int)adj[i].size() % 2 != a[i] && a[i] != -1) {
      bad[i] = true;
      c++;
    }
    if (a[i] == -1) p = i;
  }
  if (c % 2 == 1 && p == -1) {
    printf("-1\n");
    return 0;
  }
  if (c % 2 == 1) bad[p] = true;
  DFS(0);
  int counter = 0;
  for (int i = 0; i < m; i++)
    if (cnt[i] == 0) counter++;
  printf("%d\n", counter);
  for (int i = 0; i < m; i++)
    if (cnt[i] == 0) printf("%d\n", i + 1);
  return 0;
}
