#include <bits/stdc++.h>
#define N 200005

using namespace std;

int n, m;
int head[N], nex[N << 1], to[N << 1], eid[N << 1], ecnt;
int p[N], s[N];

struct light {
	int pos, state;
}lig[N];

bool cmpLight(const light &lhs, const light &rhs) { return lhs.pos < rhs.pos; }

inline int read() {
	int x = 0; char ch = getchar();
	while(!isdigit(ch)) ch = getchar();
	while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
	return x;
}
inline void addE(int u, int v, int id) {
	to[++ecnt] = v, eid[ecnt] = id;
	nex[ecnt] = head[u], head[u] = ecnt;
}

int cntOne;
int dif[N], fa[N], fe[N];
bool vis[N];

void dfs(int u) {
	if(s[u]) ++dif[u], ++cntOne;
	for(int i = head[u], v; i; i = nex[i]) {
		v = to[i];
		if(fa[v]) continue;
		fa[v] = u, fe[v] = eid[i], dfs(v);
		dif[u] += dif[v];
	}
}

int main() {
	n = read(), m = read();
	for(int i = 1; i <= n; ++i)
		lig[i].pos = read(), lig[i].state = read();
	
	sort(lig + 1, lig + n + 1, cmpLight);
	for(int i = 1; i <= n; ++i)
		p[i] = lig[i].pos, s[i] = lig[i].state;
	for(int i = n + 1; i >= 1; --i)
		s[i] = s[i] ^ s[i - 1];
		
	for(int i = 1, l, r; i <= m; ++i) {
		l = read(), r = read();
		l = lower_bound(p + 1, p + n + 1, l) - p;
		r = upper_bound(p + 1, p + n + 1, r) - p - 1;
		if(l <= r) {
			addE(l, r + 1, i), addE(r + 1, l, i);
		}
	}
	
	for(int i = 1; i <= n + 1; ++i)
		if(!fa[i]) {
			fa[i] = i;
			dfs(i);
			if(cntOne & 1) {
				puts("-1");
				return 0;
			}
		}
	
	int cnt = 0;
	for(int i = 1; i <= n + 1; ++i)
		if(dif[i] & 1)
			vis[fe[i]] = true, ++cnt;
	
	printf("%d\n", cnt);
	for(int i = 1; i <= m; ++i)
		if(vis[i])
			printf("%d ", i);
	putchar('\n');
	return 0;
}