#include <bits/stdc++.h>
using namespace std;

const int MAX = 3e5 + 5;
int n, m, mk[MAX];
pair <int, int> a[MAX];
vector <int> ans;
vector <pair <int, int> > g[MAX];

int dfs(int u, int edge_parent = -1) {
	mk[u] = 1;

	int ret = a[u].second;

	for(auto o : g[u])
		if(!mk[o.first])
			ret ^= dfs(o.first, o.second);

	if(ret) {
		if(edge_parent == -1) {
			printf("-1\n");
			exit(0);
		}

		ans.push_back(edge_parent);
	}

	return ret;
}

int main() {
	scanf("%d%d", &n, &m);

	for(int i = 1; i <= n; i++)
		scanf("%d%d", &a[i].first, &a[i].second);

	sort(a + 1, a + n + 1);

	for(int i = n + 1; i > 0; i--)
		a[i].second ^= a[i - 1].second;

	for(int i = 1; i <= m; i++) {
		int l, r; scanf("%d%d", &l, &r);
		l = lower_bound(a + 1, a + n + 1, make_pair(l, -1)) - a;
		r = upper_bound(a + 1, a + n + 1, make_pair(r, +2)) - a;

		if(l == r)
			continue;

		g[l].push_back({r, i});
		g[r].push_back({l, i});
	}

	for(int i = 1; i <= n; i++) {
		if(!mk[i])
			dfs(i);
	}

	sort(ans.begin(), ans.end());

	printf("%d\n", (int) ans.size());

	for(int i = 0; i < (int) ans.size(); i++) {
		printf("%d", ans[i]);
		printf(i == (int) ans.size() - 1 ? "\n" : " ");
	}

	return 0;
}