#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+1;
int m, n; map<int,int> bomb; vector<pair<int,int>> g[N]; 
vector<int> b, x, s; bool visited[N];
inline void read_bombs() {
	for (int a, b, i = 0; i < n; ++i) 
    	cin >> a >> b, bomb[a] = b;
	for (auto &q: bomb) 
		b.push_back(q.second), q.second = b.size()-1;
	b.push_back(0), x.push_back(b.front()), bomb[INT_MAX] = n;
	for (int i = 0, j = 1; i < n; i = j++) 
		x.push_back(b[j] != b[i]); }
inline void read_cord(int i) {
	int l, r; 
	cin >> l >> r, 
    l = bomb.lower_bound(l)->second, r = bomb.lower_bound(r+1)->second,
    g[l].emplace_back(i,r), g[r].emplace_back(i,l); }
int dfs(int u, int p = -1) {
	int t = x[u];
	visited[u] = true; 
	for (auto e: g[u]) 
    	if (e.second != p and not visited[e.second] and dfs(e.second,u)) 
    		s.push_back(e.first), t ^= 1;
	return t; }
inline void write_ans() {
    cout << s.size() << "\n";
    sort(s.begin(), s.end());
    for (auto cord: s) 
      cout << cord <<  ' '; }
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cin >> n >> m, read_bombs();
	for (int i = 1; i <= m; ++i) 
		read_cord(i);
	for (int i = 0; i <= n; ++i) 
    	if (not visited[i] and dfs(i)) 
    		cout << -1, exit(0);
    write_ans(); }