#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, m;
pair<int,int> p[N];
struct node{
	int v, ne, id;
}edge[N << 1];
int head[N], tot;
void add(int x, int y, int id)
{
	edge[++tot].v = y;
	edge[tot].id = id;
	edge[tot].ne = head[x];
	head[x] = tot;
}
int sta[N], vis[N];
int siz[N], cnt[N];
int tot1, tot2;
void dfs(int son, int fa, int id)
{
	siz[son] = sta[son];
	vis[son] = 1;
	tot2 += sta[son];
	for (int i = head[son]; i; i = edge[i].ne)
	{
		if (edge[i].v == fa) continue;
		if (vis[edge[i].v]) continue;
		dfs(edge[i].v, son, edge[i].id);
		siz[son] += siz[edge[i].v];
	}
	cnt[id] = siz[son] % 2;
}
int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)
	scanf("%d%d", &p[i].first, &p[i].second);
	sort(p + 1, p + n + 1);
	int pre = 0;
	for (int i = 1; i <= n; i++)
	{
		if (pre != p[i].second) sta[i] = 1;
		else sta[i] = 0;
		pre ^= sta[i];
		if (sta[i]) tot1++;
	}
	sta[n + 1] = pre;
//	for (int i = 1; i <= n + 1; i++)
//	cout << sta[i] << " ";
//	cout <<endl;
	if (sta[n + 1]) tot1++;
	if (tot1 == 0)
	{
		printf("0\n\n");
		return 0;
	}
	int st = -1;
	for (int i = 1; i <= m; i++)
	{
		int l, r;
		scanf("%d%d", &l, &r);
		int x = lower_bound(p + 1, p + n + 1, make_pair(l, 0)) - p;
		int y = upper_bound(p + 1, p + n + 1, make_pair(r, 1)) - p - 1;
		if (x > y) continue;
		if (st == -1) st = x;
		add(x, y + 1, i);
		add(y + 1, x, i);
//		cout << x<<" "<< y + 1 <<i << endl;
	}
	for (int i = 1; i <= n + 1; i++)
	{
		tot2 = 0;
		if (!vis[i]) dfs(i, 0, 0);
//		cout << i << tot2<<endl;
		if (tot2 % 2) 
		{
			printf("-1\n");
			return 0;
		}
	}
	vector<int> ans;
	for (int i = 1; i <= m; i++)
		if (cnt[i]) ans.push_back(i);
	printf("%d\n", ans.size());
	for (int i = 0; i < ans.size(); i++)
	{
		if (i > 0) printf(" ");
		printf("%d", ans[i]);
	}
	printf("\n");
}