#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
#define fst first
#define snd second
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


struct Edge {
  int u, v;
  Edge(int u, int v) : u(u), v(v) {}
};
using Edges = vector<Edge>;


template<typename T>
struct LinearSystemIncidence {
  struct sEdge {
    int id, to;
    bool fwd;
    sEdge(int i, int t, bool f) : id(i), to(t), fwd(f) {}
  };

  int n, m;
  vector<T> x;
  vector<bool> seen;
  vector<vector<sEdge>> G;
  
  LinearSystemIncidence(int n, Edges &E) : n(n), G(n) {
    m = E.size();
    for (int i = 0; i < m; ++i) {
      G[E[i].u].emplace_back(i, E[i].v, true);
      G[E[i].v].emplace_back(i, E[i].u, false);
    }
  }

  T dfs(vector<T> &c, int u) {
    seen[u] = true;
    T ret = -c[u];
    for (sEdge e : G[u]) {
      if (seen[e.to]) continue;
      T tmp = dfs(c, e.to);
      x[e.id] = tmp * (e.fwd ? 1 : -1);
      ret += tmp;
      x[e.id] = (x[e.id]%2 + 2) % 2;
    }
    return (ret%2 + 2) % 2;
  }

  pair<bool, vector<T>> solve(vector<T> &c) {
    x.assign(m, 0);
    seen.assign(n, false);
    for (int s = 0; s < n; ++s) {
      if (seen[s]) continue;
      if (dfs(c, s)) return make_pair(false, vector<T>());
    }
    return make_pair(true, x);
  }
};


int main() {
  ll n, m; cin >> n >> m;
  vector<P> ab(n);
  cin >> ab;
  sort(all(ab));

  V a(n), b(n);
  rep(i, n) tie(a[i], b[i]) = ab[i];

  V c(n+1);
  c[0] = b[0];
  rep(i, n-1) c[i+1] = b[i] ^ b[i+1];
  c[n] = b[n-1];

  Edges E;
  rep(i, m) {
    int l, r; cin >> l >> r;
    int u = lower_bound(all(a), l) - a.begin();
    int v = upper_bound(all(a), r) - a.begin();
    E.emplace_back(u, v);
  }

  LinearSystemIncidence<int> LSI(n+1, E);
  auto sol = LSI.solve(c);

  if (sol.first) {
    int sum = 0;
    rep(i, m) sum += sol.second[i];
    cout << sum << endl;
    rep(i, m) if (sol.second[i]) cout << (i+1) << " ";
    cout << endl;
  }
  else {
    cout << -1 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 18416