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 mod = 1e9 + 7;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const int maxn = 3e5 + 10;
vector<pair<int, int> > adjlist[maxn];
int d[maxn];
bool vis[maxn];
pair<int, int> p[maxn];
vector<int> ans;
void dfs(int i, int last, int eidx) {
  vis[i] = true;
  p[i] = {last, eidx};
  for (pair<int, int> j : adjlist[i]) {
    if (vis[j.first] == true and j.first != last) {
      int x = i;
      bool done[maxn];
      memset(done, 0, sizeof(done));
      while (p[x].first != -1 and done[x] == false) {
        done[x] = true;
        ans.push_back(p[x].second);
        x = p[x].first;
      }
      ans.push_back(j.second);
      sort(ans.begin(), ans.end());
      cout << ans.size() << endl;
      for (auto& x : ans) cout << x << endl;
      exit(0);
    }
    if (!vis[j.first] and d[j.first] != 1) dfs(j.first, i, j.second);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  bool mainans = true;
  for (int i = 1; i <= n; i++) {
    cin >> d[i];
    if (d[i] == 1) mainans = false;
  }
  if (mainans) {
    cout << 0 << endl;
    exit(0);
  }
  map<pair<int, int>, int> mp;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    adjlist[u].push_back({v, i});
    adjlist[v].push_back({u, i});
    mp[{u, v}] = i;
    mp[{v, u}] = i;
    if (d[u] != 0 and d[v] != 0) {
      cout << "1\n";
      cout << i << endl;
      exit(0);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (d[i] != 1 and vis[i] == false) {
      dfs(i, -1, -1);
    }
  }
  cout << -1 << endl;
  return 0;
}
