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 = 321000;
int d[MAXN];
vector<int> g[MAXN];
set<int> g1[MAXN];
set<int> g2[MAXN];
bool flag = 0;
int p, n, m, sum;
int par[MAXN];
bool vis[MAXN];
int deg[MAXN];
vector<pair<int, int> > edges;
void dfs(int u) {
  for (set<int>::iterator it = g1[u].begin(); it != g1[u].end(); it++) {
    dfs((*it));
  }
  if (deg[u] % 2 != d[u]) {
    deg[u]--;
    deg[par[u]]--;
    g2[par[u]].insert(u);
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> d[i];
    if (d[i] == -1)
      flag = 1, p = i;
    else
      sum += d[i];
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    edges.push_back({x, y});
    g[x].push_back(y);
    g[y].push_back(x);
  }
  if (flag == 0 && sum % 2 == 1) {
    cout << "-1\n";
    return 0;
  }
  if (sum % 2 == 1) {
    for (int i = 1; i <= n; i++) {
      if (i == p) {
        d[i] = 1;
        continue;
      }
      if (d[i] == -1) {
        d[i] = 0;
      }
    }
  }
  vis[1] = 1;
  queue<int> q;
  q.push(1);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int j = 0; j < g[u].size(); j++) {
      int v = g[u][j];
      if (vis[v] == 0) {
        deg[u]++;
        deg[v]++;
        par[v] = u;
        g1[u].insert(v);
        vis[v] = 1;
        q.push(v);
      }
    }
  }
  dfs(1);
  for (int i = 1; i <= n; i++) {
    if (deg[i] % 2 != d[i]) {
      cout << "-1\n";
      return 0;
    }
  }
  vector<int> ans;
  for (int i = 0; i < m; i++) {
    if (g1[edges[i].first].find(edges[i].second) != g1[edges[i].first].end() &&
        g2[edges[i].first].find(edges[i].second) == g2[edges[i].first].end()) {
      ans.push_back(i + 1);
    }
    if (g1[edges[i].second].find(edges[i].first) != g1[edges[i].second].end() &&
        g2[edges[i].second].find(edges[i].first) != g2[edges[i].second].end()) {
      ans.push_back(i + 1);
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}
