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 string namePro = "tmp";
int d[1000007];
vector<pair<int, int> > adj[1000007];
bool check[1000007];
bool valid[1000007];
bool visited[1000007];
bool DFS(int u, int isStart) {
  if (d[u] == -1) return 1;
  if (valid[u] && !isStart) {
    valid[u] = 0;
    return 1;
  }
  bool res = 0;
  for (int i = (0); i <= ((int)adj[u].size() - 1); ++i) {
    int v = adj[u][i].first;
    int w = adj[u][i].second;
    if (check[w]) continue;
    if (visited[v] < adj[v].size() && visited[u] < adj[u].size()) {
      ++visited[v];
      ++visited[u];
      check[w] = 1;
      res |= DFS(v, 0);
    }
    if (res) break;
  }
  return res;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = (1); i <= (n); ++i) scanf("%d", &d[i]);
  for (int i = (1); i <= (m); ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    adj[u].push_back(make_pair(v, i));
    adj[v].push_back(make_pair(u, i));
  }
  for (int i = (1); i <= (n); ++i) {
    if (d[i] == -1) continue;
    if (adj[i].size() % 2 != d[i]) valid[i] = 1;
  }
  for (int i = (1); i <= (n); ++i) {
    if (valid[i]) {
      if (DFS(i, 1))
        valid[i] = 0;
      else {
        puts("-1");
        return 0;
      }
    }
  }
  int cnt = 0;
  for (int i = (1); i <= (m); ++i) {
    if (!check[i]) ++cnt;
  }
  printf("%d\n", cnt);
  for (int i = (1); i <= (m); ++i) {
    if (!check[i]) printf("%d\n", i);
  }
  return 0;
}
