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 d[1000001];
vector<pair<int, int>> adj[300001];
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> cc;
  for (int i = 1; i <= n; i++) {
    cin >> d[i];
  }
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(make_pair(v, i));
    adj[v].push_back(make_pair(u, i));
  }
  for (int i = 1; i <= n; i++) {
    if (d[i] == -1) {
      continue;
    } else if (d[i] % 2 != adj[i].size() % 2) {
      cc.push_back(i);
    }
  }
  if (cc.size() > 2) {
    cout << "-1";
  } else if (cc.size() == 0) {
    cout << "0";
  } else if (cc.size() == 2) {
    for (int i = 0; i < adj[cc[0]].size(); i++) {
      if (adj[cc[0]][i].first == cc[1]) {
        cout << "1" << endl << adj[cc[0]][i].second;
        exit(0);
      }
    }
    cout << "-1";
  } else {
    for (int i = 0; i < adj[cc[0]].size(); i++) {
      if (d[adj[cc[0]][i].first] == -1) {
        cout << "1" << endl << adj[cc[0]][i].second;
        exit(0);
      }
    }
    cout << "-1";
  }
  return 0;
}
