#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
const int dm = 1 << 21;
char dn[dm], * di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}
ll E[400004];
int he[100002];
int tmp[200002];
void pakuri_sort1(int N, int A[]) {
	const int b = 8;
	const int m = (1 << 8) - 1, m2 = (1 << 6) - 1;
	int kazu[1 << b] = {}, kazu2[1 << b] = {}, kazu3[1 << b] = {}, kazu4[1 << 6] = {};
	rep(i, N) kazu[A[i] & m]++;
	rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
	for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] & m]] = A[i];
	rep(i, N) kazu2[tmp[i] >> b & m]++;
	rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
	for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> b & m]] = tmp[i];
	rep(i, N) kazu3[A[i] >> 2 * b & m]++;
	rep(i, (1 << b) - 1) kazu3[i + 1] += kazu3[i];
	for (int i = N - 1; i >= 0; i--) tmp[--kazu3[A[i] >> 2 * b & m]] = A[i];
	rep(i, N) kazu4[tmp[i] >> 3 * b & m2]++;
	rep(i, (1 << b) - 1) kazu4[i + 1] += kazu4[i];
	for (int i = N - 1; i >= 0; i--) A[--kazu4[tmp[i] >> 3 * b & m2]] = tmp[i];
}
void pakuri_sort2(int N, ll A[]) {
	const int b = 8;
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) E[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[E[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[E[i] >> k * b & ((1 << b) - 1)]] = E[i];
	}
}

const int ma = (1 << 30) - 1;
bool B[100002], kotae[200002];
int kazu;
bool dfs(int p) {
	tmp[p] = -1;
	bool b = B[p];
	for (int to = he[p]; to; to = E[to] & ma) {
		if (tmp[E[to] >> 30] >= 0) {
			kotae[to >> 1] = dfs(E[to] >> 30);
			b ^= kotae[to >> 1];
		}
	}
	kazu += b;
	return b;
}

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint(), M = getint();

	int A[100001];
	rep1(i, N) {
		int a = 0;
		if (ci - cn + 16 > cm) {
			while ((ct = getcha()) >= '0') a = a * 10 + ct - '0';
			A[i] = a + (getcha() - '0' << 30);
			getcha();
		}
		else {
			while ((ct = *ci++) >= '0') a = a * 10 + ct - '0';
			A[i] = a + (*ci++ - '0' << 30);
			ci++;
		}
	}
	pakuri_sort1(N, A + 1);
	int mae = 0;
	rep1(i, N) {
		int b = A[i] >> 30;
		if (mae != b) {
			mae = b;
			B[i] = 1;
		}
	}
	if (mae) B[N + 1] = 1;

	ll L[200001], R[200001];
	rep1(k, M) {
		L[k] = (ll(k) << 32) + getint();
		R[k] = (ll(k) << 32) + getint();
	}
	pakuri_sort2(M, L + 1);
	auto tekitou = tmp;
	int j = 1;
	rep1(i, M) {
		int l = L[i] & ma;
		while (j <= N && (A[j] & ma) < l) j++;
		tekitou[L[i] >> 32] = j;
	}
	pakuri_sort2(M, R + 1);
	j = 1;
	rep1(i, M) {
		int r = R[i] & ma;
		while (j <= N && (A[j] & ma) <= r) j++;
		int k = R[i] >> 32;
		int j2 = tekitou[k];
		k <<= 1;
		E[k] = (ll(j) << 30) + he[j2];
		he[j2] = k++;
		E[k] = (ll(j2) << 30) + he[j];
		he[j] = k;
	}

	int NG = 0;
	rep1(i, N + 1) {
		if (tmp[i] >= 0) {
			NG |= dfs(i);
		}
	}
	if (NG) printf("-1");
	else {
		if (kazu == 0) {
			*di++ = '0';
			*di++ = '\n';
		}
		else putint(kazu);
		rep1(i, M) if (kotae[i]) putint(i);
	}
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 11392