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, u, v, res = 0;
int root;
int deg[N], d[N];
bool dd[N], choose[N];
vector<pair<int, int> > a[N];
void dfs(int u) {
  dd[u] = 1;
  for (int i = (0), _b = (a[u].size()); i < _b; ++i) {
    int v = a[u][i].first;
    int id = a[u][i].second;
    if (dd[v]) continue;
    dfs(v);
    if (d[v] != -1 && d[v] != deg[v] % 2) {
      choose[id] = 1;
      deg[u]++, deg[v]++;
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  root = 1;
  for (int i = (1), _b = (n); i <= _b; ++i) {
    scanf("%d", &d[i]);
    if (d[i] == -1) root = i;
  }
  for (int i = (1), _b = (m); i <= _b; ++i) {
    scanf("%d%d", &u, &v);
    a[u].push_back(pair<int, int>(v, i));
    a[v].push_back(pair<int, int>(u, i));
  }
  dfs(root);
  for (int i = (1), _b = (n); i <= _b; ++i)
    if (d[i] != -1 && d[i] != deg[i] % 2) {
      cout << -1 << endl;
      return 0;
    }
  for (int i = (1), _b = (m); i <= _b; ++i) res += (choose[i]);
  cout << res << endl;
  for (int i = (1), _b = (m); i <= _b; ++i)
    if (choose[i]) cout << i << endl;
  return 0;
}
