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[300000];
vector<pair<int, int> > adj[300000];
bool vis[300000];
vector<int> ans;
int dfs(int u) {
  vis[u] = 1;
  int ret = d[u];
  for (auto v : adj[u]) {
    if (vis[v.first]) continue;
    int res = dfs(v.first);
    if (res) ans.push_back(v.second);
    ret ^= res;
  }
  if (d[u] == -1) ret = 0;
  return ret;
}
int main() {
  scanf("%d %d", &n, &m);
  bool minus_one = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &d[i]);
    if (d[i] == -1) minus_one = 1;
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--;
    v--;
    adj[u].push_back({v, i + 1});
    adj[v].push_back({v, i + 1});
  }
  memset((vis), 0, sizeof(vis));
  if (minus_one) {
    for (int u = 0; u < n; u++) {
      if (d[u] == -1) {
        dfs(u);
        break;
      }
    }
  } else {
    if (dfs(0)) return 0 * puts("-1");
  }
  printf("%d\n", ans.size());
  for (auto i : ans) printf("%d\n", i);
  return 0;
}
