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;
vector<vector<pair<int, int> > > v(300001);
vector<int> ans;
int d[300001], vis[300001], par[300001];
void dfs(int curr, int from) {
  vis[curr] = 1;
  for (int i = 0; i < v[curr].size(); i++) {
    if (!vis[v[curr][i].first])
      par[v[curr][i].first] = curr, dfs(v[curr][i].first, v[curr][i].second);
  }
  if (d[curr] == 1 and from != -1) {
    ans.push_back(from);
    d[par[curr]] = 1 - d[par[curr]];
  }
}
int main() {
  int n, m, f = 1, a = 0, s = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> d[i];
    if (d[i] != -1) s += d[i];
  }
  if (s % 2) {
    for (int i = 1; i <= n; i++)
      if (d[i] == -1) {
        d[i] = 1;
        a++;
        break;
      }
    if (!a) {
      cout << -1;
      return 0;
    }
    for (int i = 1; i <= n; i++)
      if (d[i] == -1) d[i] = 0;
  }
  for (int i = 0, x, y; i < m; i++) {
    cin >> x >> y;
    v[x].push_back({y, i + 1});
    v[y].push_back({x, i + 1});
  }
  dfs(1, -1);
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << endl;
}
