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;
int n, m;
int d[300010], deg[300010];
vector<pair<int, int> > a[300010];
vector<pair<int, int> > edge;
bool check[300010];
int main() {
  cin >> n >> m;
  int i, j;
  for (i = 1; i <= n; i++) cin >> d[i];
  for (i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    a[u].push_back(make_pair(v, i));
    deg[u]++;
    a[v].push_back(make_pair(u, i));
    edge.push_back(make_pair(u, v));
    deg[v]++;
    check[i] = true;
  }
  for (i = 0; i < m; i++) {
    int x = edge[i].first;
    int y = edge[i].second;
    if (d[x] == -1 && d[y] != -1) {
      if ((d[y] % 2) != (deg[y] % 2) && deg[y] > 0) {
        check[i] = false;
        deg[y] -= 1;
      }
    } else if (d[x] != -1 && d[y] == -1) {
      if ((d[x] % 2) != (deg[x] % 2) && deg[x] > 0) {
        check[i] = false;
        deg[x] -= 1;
      }
    }
  }
  for (i = 0; i < m; i++) {
    int x = edge[i].first;
    int y = edge[i].second;
    if (d[x] != -1 && d[y] != -1) {
      if ((d[y] % 2) != (deg[y] % 2) && (d[x] % 2) != (deg[x] % 2) &&
          deg[x] > 0 && deg[y] > 0) {
        deg[x] -= 1;
        deg[y] -= 1;
        check[i] = false;
      }
    }
  }
  bool chk = true;
  for (i = 1; i <= n; i++) {
    if (d[i] != -1) {
      if ((d[i] % 2) != (deg[i] % 2)) {
        chk = false;
        break;
      }
    }
  }
  if (!chk)
    printf("-1\n");
  else {
    int cnt = 0;
    for (i = 0; i < m; i++)
      if (check[i]) cnt++;
    printf("%d\n", cnt);
    for (i = 0; i < m; i++) {
      if (check[i]) printf("%d\n", i + 1);
    }
  }
  return 0;
}
