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 maxn = 3e5 + 5;
vector<pair<int, int> > G[maxn];
int d[maxn];
vector<int> ans;
int flag[maxn];
int vis[maxn];
void dfs(int root, int num) {
  vis[root] = 1;
  int x = 0;
  for (int i = 0; i < G[root].size(); i++) {
    int v = G[root][i].first;
    int p = G[root][i].second;
    if (vis[v] == 1) continue;
    dfs(v, p);
    x ^= flag[p];
  }
  if (x == d[root] || d[root] == -1) return;
  flag[num] = 1;
  if (num != 0) ans.push_back(num);
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int root = 1;
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &d[i]);
    if (d[i] == -1) root = i;
    if (d[i] != -1) sum += d[i];
  }
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(pair<int, int>(v, i));
    G[v].push_back(pair<int, int>(u, i));
  }
  if (d[root] != -1 && sum % 2 == 1)
    printf("-1\n");
  else {
    dfs(root, 0);
    sort(ans.begin(), ans.end());
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) {
      printf("%d\n", ans[i]);
    }
  }
  return 0;
}
