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;
using ii = pair<int, int>;
map<int, int> e[300001];
map<ii, int> ecount;
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  vector<int> d(n + 1);
  vector<int> deg(n + 1);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &d[i]);
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    e[a][b]++;
    deg[a]++;
    e[b][a]++;
    deg[b]++;
    ecount[make_pair(a, b)] = ecount[make_pair(b, a)] = i + 1;
  }
  vector<bool> removeEdge(m + 1);
  for (int i = 1; i <= n; i++) {
    if (d[i] == -1) continue;
    if (deg[i] % 2 == d[i]) continue;
    for (auto iter = e[i].begin(); iter != e[i].end();) {
      if (d[iter->first] == -1) {
        iter->second--;
        deg[i]--;
        removeEdge[ecount[make_pair(i, iter->first)]] = true;
        if (iter->second == 0) iter = e[i].erase(iter);
      } else if (d[iter->first] != deg[iter->first] % 2) {
        iter->second--;
        deg[i]--;
        deg[iter->first]--;
        removeEdge[ecount[make_pair(i, iter->first)]] = true;
        e[iter->first][i]--;
        if (e[iter->first][i] == 0) e[iter->first].erase(i);
      } else {
        ++iter;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (d[i] != -1 && deg[i] % 2 != d[i]) {
      printf("-1");
      return 0;
    }
  }
  vector<int> ans;
  for (int i = 1; i <= m; i++)
    if (!removeEdge[i]) ans.push_back(i);
  printf("%d\n", ans.size());
  for (auto& a : ans) printf("%d\n", a);
  return 0;
}
