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;
long n, m, d[300001] = {};
bool vis[300001] = {};
bool used[300001] = {};
set<pair<long, long> > v[300001];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (long long f = 1; f <= n; ++f) {
    cin >> d[f];
    if (d[f] == -1) {
      cout << 0;
      return 0;
    }
  }
  for (long long f = 1; f <= m; ++f) {
    long x, y;
    cin >> x >> y;
    v[x].insert(make_pair(y, f));
    v[y].insert(make_pair(x, f));
  }
  for (long long f = 1; f <= n; ++f) {
    if (v[f].size() > 1) {
      set<pair<long, long> >::iterator it = v[f].begin();
      long now = 1;
      ++it;
      while (it != v[f].end()) {
        set<pair<long, long> >::iterator chck = it;
        --chck;
        if ((*it).first == (*chck).first) {
          ++now;
        }
        if ((*it).first != (*chck).first || it == --v[f].end()) {
          if (now % 2 == 1) {
            set<pair<long, long> >::iterator it1 = v[f].begin();
            cout << now << '\n';
            ;
            while (it1 != it) {
              cout << (*it1).second << '\n';
              ++it1;
            }
            return 0;
          } else {
            now = 0;
          }
        }
        ++it;
      }
    }
    if (v[f].size() == 1) {
      set<pair<long, long> >::iterator it = v[f].begin();
      cout << 1 << '\n' << (*it).second;
      return 0;
    }
  }
  cout << -1;
  return 0;
}
