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, D[300005];
bool mark[300005];
vector<pair<int, int> > adj[300005];
vector<int> ans;
int dfs(int nd) {
  mark[nd] = 1;
  int t = D[nd];
  for (int i = 0; i < adj[nd].size(); i++) {
    int ch = adj[nd][i].first, id = adj[nd][i].second;
    if (mark[ch]) continue;
    if (dfs(ch)) {
      ans.push_back(id);
      t ^= 1;
    }
  }
  return t;
}
int main() {
  scanf("%d", &N);
  scanf("%d", &M);
  for (int i = 1; i <= N; i++) scanf("%d", &D[i]);
  for (int i = 0; i < M; i++) {
    int u, v;
    scanf("%d", &u);
    scanf("%d", &v);
    adj[u].push_back(make_pair(v, i));
    adj[v].push_back(make_pair(u, i));
  }
  int mx = 0, cnt = 0;
  for (int i = 1; i <= N; i++) {
    if (D[i] >= 0)
      mx ^= D[i];
    else
      cnt++;
  }
  if (mx && !cnt) {
    puts("-1");
    return 0;
  }
  for (int i = 1; i <= N; i++)
    if (D[i] < 0) {
      if (mx) {
        mx ^= 1;
        D[i] = 1;
      } else
        D[i] = 0;
    }
  if (dfs(1)) {
    puts("-1");
    return 0;
  }
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++) printf("%d\n", ans[i] + 1);
}
