#include <vector>
#include <set>

struct adjucency_matrix_equation {
  int V;
  int E;
  std::vector<std::vector<std::pair<int, int>>> G;
  adjucency_matrix_equation(int n): V(n), E(0), G(n) {}

  void add_edge(int v, int u) {
    G[v].emplace_back(u + V, E);
    G[u].emplace_back(v, E);
    E++;
  }
  
  template<class T>
  std::vector<T> solve(const std::vector<T>& c) const {
    std::vector<int> vis(V, 0);
    std::vector<T> ans(E, 0);

    auto dfs = [&](auto f, int v) -> T {
      vis[v] = 1;
      T r = c[v];
      for(auto e: G[v]) {
        int t = e.first;
        int ei = e.second;
        if(vis[t < V ? t : t - V]) continue;
        T y;
        if(t < V) ans[ei] = (y = f(f, t));
        else      ans[ei] = T(0) - (y = f(f, t - V));
        r = r + y;
      }
      return r;
    };

    for(int v = 0; v < V; v++) {
      if(vis[v]) continue;
      T y = dfs(dfs, v);
      if(y != T(0)) return std::vector<T>();
    }
    return ans;
  }
};

#include <iostream>
using i64 = long long;
template<i64 M> struct modint { i64 a;
  constexpr modint(const i64 x = 0): a((x%M+M)%M){}
  constexpr i64 value() const { return a; }
  constexpr modint inv() const { return this->pow(M-2); }
  constexpr modint pow(i64 r) const {
    modint ans(1); modint aa = *this;
    while(r) { if(r & 1) ans *= aa; aa *= aa; r >>= 1; }
    return ans;
  }
  constexpr modint& operator=(const i64 r) { a = (r % M + M) % M; return *this; }
  constexpr modint& operator+=(const modint r) { a += r.a; if(a >= M) a -= M; return *this; }
  constexpr modint& operator-=(const modint r) { a -= r.a; if(a < 0) a += M; return *this; }
  constexpr modint& operator*=(const modint r) { a = a * r.a % M; return *this; }
  constexpr modint& operator/=(const modint r) { (*this) *= r.inv(); return *this; }
  constexpr modint operator+(const modint r) const { return modint(*this) += r; }
  constexpr modint operator-(const modint r) const { return modint(*this) -= r; }
  constexpr modint operator*(const modint r) const { return modint(*this) *= r; }
  constexpr modint operator/(const modint r) const { return modint(*this) /= r; }
  constexpr bool operator!=(const modint r) const { return this->value() != r.value(); }
};

template<const i64 M> std::ostream& operator<<(std::ostream& os, const modint<M>& m) { os << m.value(); return os; }


#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

using bin = modint<2>;

int main() {
  int N, M;
  cin >> N >> M;
  vector<i64> A(N), B(N);
  vector<i64> L(M), R(M);
  vector<i64> X;
  rep(i,0,N) {
    cin >> A[i] >> B[i];
    X.emplace_back(A[i]);
  }
  X.emplace_back(0);
  sort(all(X));
  vector<int> bs(N + 2);
  rep(i,0,N) {
    int iter = lower_bound(all(X), A[i]) - begin(X);
    bs[iter] = B[i];
  }

  adjucency_matrix_equation equ(N + 1);

  rep(i,0,M) {
    cin >> L[i] >> R[i];
    L[i] = lower_bound(all(X), L[i]) - begin(X);
    R[i] = upper_bound(all(X), R[i]) - begin(X);
    equ.add_edge(L[i] - 1, R[i] - 1);
  }

  vector<bin> c(N + 1);
  rep(i,0,N + 1) {
    if(bs[i] != bs[i + 1]) {
      c[i] = bin(1);
    }
  }

  auto ans = equ.solve(c);
  if(ans.empty()) {
    cout << -1 << endl;
    return 0;
  }
  vector<int> vec;
  rep(i,0,M) {
    if(ans[i].value() == 1) {
      vec.push_back(i + 1);
    }
  }
  cout << vec.size() << "\n";
  rep(i,0,vec.size()) {
    cout << vec[i] << " \n"[i + 1 == vec.size()];
  }
}


Measured memory_bytes: 29812