// WA TLE
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <map>
#include <numeric>
#include <iostream>

using namespace std;
typedef vector<int> vI;
typedef vector<vI> vvI;
typedef pair<int, vI> IvI;
typedef vector<IvI> vIvI;
typedef vector<vIvI> vvIvI;
typedef tuple<int, int, int> III;
typedef vector<III> vIII;
typedef map<int, vI> i2vI;
typedef pair<int, int> II;
typedef vector<II> vII;

template<typename T1, typename T2, typename T3>
ostream& operator<<(ostream& os, tuple<T1, T2, T3> const& v) {
  return os << "<" << get<0>(v) << "," << get<1>(v) << "," << get<2>(v) << "]";
}

template<typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2> const& v) {
  return os << "<" << get<0>(v) << "," << get<1>(v) << ">";
}

template<typename T>
ostream& operator<<(ostream& os, vector<T> const& v) {
  os << "[";
  for (size_t i = 0; i < v.size(); i++) 
    os << (i == 0 ? "" : ",") << v[i];
  return os << "]";
}


vI solve(vI & bombs, vIII const& sws, bool &solved) {
  if (accumulate(bombs.begin(), bombs.end(), 0) == 0) {
    return vI();
  }
  vvI g(bombs.size() + 1);
  vI edge_nums, bsums;
  for (size_t j = 0; j < sws.size(); j++) {
    auto sw = sws[j];
    int l = get<0>(sw);
    int r = get<1>(sw);
    int i = get<2>(sw);
    g[l].push_back(j);
    g[r].push_back(j);
    edge_nums.push_back(i);
    bsums.push_back(l + r);
  }
  vI root(bombs.size() + 1, -1);
  vI parent(bombs.size() + 1, -1);
  vI depth(bombs.size() + 1, -1);
  vI changed;
  for (size_t i = 0; i < bombs.size() + 1; i++) {
    if ((i == 0 && bombs[i] == 1) ||
        (i == bombs.size() && bombs[i - 1] == 1) ||
        (i > 0 && i < bombs.size() && bombs[i] != bombs[i - 1])) {
      changed.push_back(i);
      if (g[i].size() == 0) {
        solved = false;
//        cerr << "g[" << i << "]=" << g[i] << ",g=" << g << endl;
        return vI();
      }
      if (root[i] < 0) {
        root[i] = i;
        depth[i] = 0;
        vI q(1, i);
        for (int d = 0; !q.empty(); d++) {
          vI next_q;
          for (auto j : q) {
            for (auto e : g[j]) {
              int k = bsums[e] - j;
              if (root[k] < 0) {
                root[k] = i;
                depth[k] = d + 1;
                parent[k] = e;
                next_q.push_back(k);
              }
            }
          }
          q.swap(next_q);
        }
      }
    }
  }
  vI r;
  vI di;
  vI count(bombs.size() + 1, 0);
  for (size_t i = 1; i < changed.size(); i+= 2) {
    di.push_back(changed[i - 1]);
    di.push_back(changed[i]);
    count[root[changed[i - 1]]] = 1 - count[root[changed[i - 1]]];
    count[root[changed[i]]] = 1 - count[root[changed[i]]];
  }
#if 0
    cerr << bombs << endl;
    cerr << root << endl;
    cerr << count << endl;
#endif
  sort(di.begin(), di.end(),
       [&](auto lhs, auto rhs){ return depth[lhs] < depth[rhs]; });
  if (di.size() == 0) {
    return vI();
  }
  vI q;
  while (di.size() > 0 || q.size() > 0) {
//    cerr << "di=" << di << ",q=" << q << endl;
    while (q.size() == 0 ||
           (di.size() > 0 && depth[di.back()] == depth[q.back()])) {
      q.push_back(di.back());
      di.pop_back();
    }
    sort(q.begin(), q.end());
    vI q1;
    for (size_t i = 0; i < q.size(); i++) {
      if (i < q.size() - 1 && q[i] == q[i + 1]) {
        i++;
        continue;
      }
      q1.push_back(q[i]);
    }
//    cerr << "di=" << di << ",q1=" << q1 << endl;
    vI next_q;
    while (!q1.empty()) {
      int i = q1.back();
      q1.pop_back();
      if (parent[i] < 0) {
        solved = false;
        return vI();
      }
      r.push_back(edge_nums[parent[i]]);
      int j = bsums[parent[i]] - i;
      next_q.push_back(j);
    }
    q.swap(next_q);
  }
  sort(r.begin(), r.end());
  return r;
}

int main() {
  size_t n, m;
  cin >> n >> m;
  vII bombs(n);
  for (size_t i = 0; i < n; i++) {
    cin >> bombs[i].first >> bombs[i].second;
  }
  sort(bombs.begin(), bombs.end());
  vI bpos, bval;
  for (auto b : bombs) {
    bval.push_back(b.first);
    bpos.push_back(b.second);
  }
  vIII sws;
  for (size_t i = 0; i < m; i++) {
    int l, r; cin >> l >> r;
    l = lower_bound(bval.begin(), bval.end(), l) - bval.begin();
    r = upper_bound(bval.begin(), bval.end(), r) - bval.begin();
//    cerr << "i=" << i << ",l=" << l << ",r=" << r << std::endl;
    if (l != r) {
      sws.push_back(III(l, r, i + 1));
    }
  }
  sort(sws.begin(), sws.end());
//  cerr << sws << endl;
  bool solved = true;
  vI r = solve(bpos, sws, solved);
  if (!solved) {
    cout << -1 << endl;
  } else {
    cout << r.size() << endl;
    for (size_t j = 0; j < r.size(); j++) {
      cout << (j == 0 ? "" : " ") << r[j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 15080