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 = 4e5 + 5;
int n, m, d[N], vis[N];
vector<pair<int, int> > e[N];
vector<int> ans;
bool dfs(int u) {
  vis[u] = 1;
  for (int i = 0; i < e[u].size(); i++) {
    int v = e[u][i].first;
    if (vis[v]) continue;
    if (dfs(v)) {
      ans.push_back(e[u][i].second);
      d[v] = 0;
      d[u] ^= 1;
    }
  }
  return d[u];
}
int main() {
  cin >> n >> m;
  int sum = 0, rt = -1;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &d[i]);
    sum += (d[i] == 1);
    if (d[i] == -1) rt = i;
  }
  int u, v;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    e[u].push_back(pair<int, int>(v, i));
    e[v].push_back(pair<int, int>(u, i));
  }
  if (sum % 2 && rt == -1) {
    puts("-1");
    return 0;
  }
  if (sum % 2)
    d[rt] = 1;
  else
    rt = 1;
  for (int i = 1; i <= n; i++) {
    if (d[i] == -1) d[i] = 0;
  }
  dfs(rt);
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) printf("%d ", ans[i]);
  printf("\n");
  return 0;
}
