#include <bits/stdc++.h>
using namespace std;
const int MX = 300010;
vector<pair<int, int> > vec[MX];
int d[MX];
bool visited[MX];
vector<int> selected;
int dfs(int v) {
  visited[v] = true;
  int cnt = (d[v] == 1);
  for (pair<int, int> p : vec[v]) {
    if (!visited[p.first]) {
      visited[p.first] = true;
      int ret = dfs(p.first);
      if (ret % 2 == 1) {
        selected.push_back(p.second);
        ++cnt;
      }
    }
  }
  return cnt;
}
void solve() {
  int n, m, a, b, sum = 0, cnt = 0;
  cin >> n >> m;
  memset(visited, false, sizeof(visited));
  for (long long i = 1; i < n + 1; ++i) {
    cin >> d[i];
    if (d[i] > 0) {
      sum += d[i];
    } else if (d[i] == -1) {
      cnt++;
    }
  }
  for (long long i = 0; i < m; ++i) {
    cin >> a >> b;
    vec[a].push_back(make_pair(b, i + 1));
    vec[b].push_back(make_pair(a, i + 1));
  }
  if (sum % 2 && !cnt) {
    cout << "-1"
         << "\n";
    return;
  }
  if (sum % 2 == 1) {
    for (long long i = 1; i < n + 1; ++i) {
      if (d[i] == -1) {
        d[i] = 1;
        break;
      }
    }
  }
  dfs(1);
  int temp = 0, si = selected.size();
  cout << si << "\n";
  for (long long i = 0; i < si; ++i) {
    cout << selected[i] << "\n";
  }
}
int main() {
  bool testing = false;
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  if (testing) {
    freopen("test.txt", "rt", stdin);
    int start = clock();
    solve();
    int end = clock();
    cout << "time: " << (end - start) / (double)(CLOCKS_PER_SEC)*1000
         << " milliseconds\n";
  } else {
    solve();
  }
}
