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

#define pb push_back
#define st first
#define nd second

typedef long long ll;
typedef double db;
typedef long double ldb;
typedef complex<db> cd;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<db, db> pdd;
typedef pair<ldb, ldb> pldb;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<db> vd;
typedef vector<ldb> vldb;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpd;
typedef vector<pldb> vpldb;
typedef vector<pil> vpil;
typedef vector<pli> vpli;

int si();
ll sl();
string ss(int);
char sc();
float sf();
db sd();
ldb sld();

template<typename T> void print(T, char='\n');
template<typename T, typename... Args> void print(T, Args...);

void pi(const int&, char='\n');
void pl(const ll&, char='\n');
void pf(const float&, char='\n');
void pc(const char&, char='\n');
void pd(const db&, char='\n');
void pld(const ldb&, char='\n');
void ps(const string&, char='\n');
template<typename T> void pv(const vector<T>& v, char=' ', char='\n');
template<typename It> void out(It begin, It end, char=' ', char='\n');

ll russian(ll, ll, ll);
ll fastpow(ll, ll, ll);
ll slowpow(ll, ll, ll);
ll _gcd(ll, ll);
ll _lcm(ll, ll);
ll extgcd(ll, ll, ll&, ll&);
ll _inv(ll, ll);

const int INF = 1e9;
const ll LINF = 1e18;

const int N = 1e5 + 7, M = 2e5 + 7;
pair<int, bool> A[N];
pii I[M];
vpii G[N];
vi res;
bool vis[N];
int n, m;

bool dfs(int v)
{
	bool val = A[v].nd;
	vis[v] = true;

	for (auto& e : G[v])
		if (!vis[e.st] && dfs(e.st))
		{
			res.pb(e.nd + 1);
			val ^= 1;
		}

	return val;
}	

void read()
{
	n = si(); m = si();
	for (int i = 0; i < n; ++i)
		A[i] = {si(), si()};
	for (int i = 0; i < m; ++i)
		I[i] = {si(), si()};
}

void solve()
{
	sort(A, A + n);

	int it = 0;
	while (it < n)
	{
		if (A[it].nd)
		{
			++it;
			while (A[it].nd)
				A[it].nd = false,
				++it;
			A[it].nd = true;
		}

		++it;
	}

	for (int i = 0; i < m; ++i)
	{
		int left = I[i].st;
		int right = I[i].nd;
		// auto&& [left, right] = I[i];

		if (A[n - 1].st < left)
		{
			left = right = 0;
			continue;
		}

		int l = -1, r = n - 1;
		while (l + 1 < r)
		{
			int mid = (l + r) >> 1;
			if (A[mid].st >= left)
				r = mid;
			else
				l = mid;
		}

		left = r;

		if (A[0].st > right)
		{
			left = right = 0;
			continue;
		}

		l = 0; r = n;
		while (l + 1 < r)
		{
			int mid = (l + r) >> 1;
			if (A[mid].st <= right)
				l = mid;
			else
				r = mid;
		}

		right = l;

		G[left].pb({right + 1, i});
		G[right + 1].pb({left, i});
	}	

	for (int i = 0; i <= n; ++i)
		if (!vis[i] && dfs(i))
		{
			pi(-1);
			return;
		}

	sort(res.begin(), res.end());
	pi(res.size());
	out(res.begin(), res.end());
}

int main()
{		
	read();
	solve();

	return 0;
}

template<typename T>
T scanf_t(string&& token)
{
	T a;
	scanf(token.c_str(), &a);
	return a;
}

int si() { return scanf_t<int>("%d"); }
ll sl() { return scanf_t<ll>("%lld"); }
string ss(int n) { char T[n + 7]; scanf("%s", T); return string(T); }
char sc() { return scanf_t<char>(" %c"); }
float sf() { return scanf_t<float>("%f"); }
db sd() { return scanf_t<db>("%lf"); }
ldb sld() { return scanf_t<ldb>("%Lf"); }

template<typename T>
void print(T a, char sep)
{
	string token;
	if (is_same<T, int>::value)
		token = "%d";
	else if (is_same<T, ll>::value)
		token = "%lld";
	else if (is_same<T, string>::value)
		token = "%s";
	else if (is_same<T, char>::value)
		token = "%c";
	else if (is_same<T, float>::value)
		token = "%.6f";
	else if (is_same<T, db>::value)
		token = "%.8lf";
	else if (is_same<T, ldb>::value)
		token = "%.10Lf";
	else if (is_same<T, bool>::value)
		token = "%d";
	token.push_back(sep);

	printf(token.c_str(), a);
}

template<typename T, typename... Args>
void print(T first, Args... rest)
{
	print(first, ' ');
	print(rest...);
}

void pi(const int& a, char sep) { printf("%d%c", a, sep); }
void pl(const ll& a, char sep) { printf("%lld%c", a, sep); }
void pf(const float& a, char sep) { printf("%.6f%c", a, sep); }
void pc(const char& a, char sep) { printf("%c%c", a, sep); }
void pd(const db& a, char sep) { printf("%.8lf%c", a, sep); }
void pld(const ldb& a, char sep) { printf("%.10Lf%c", a, sep); }
void ps(const string& a, char sep) { printf("%s%c", a.c_str(), sep); }

template<typename It>
void out(It begin, It end, char sep, char endl)
{
	if (begin == end)
	{
		printf("%c", endl);
		return;
	}

	while (begin + 1 != end)
		print(*begin, sep),
		++begin;

	if (begin != end)
		print(*begin, ' '),
		printf("%c", endl);
}

template<typename T>
void pv(const vector<T>& v, char sep, char endl) { out(v.begin(), v.end(), sep, endl); }

ll russian(ll a, ll k, ll m)
{
	ll res = 0;
	while (k)
	{
		if (k & 1LL)
			res = (res + a) % m;
		a = (a + a) % m;
		k >>= 1LL;
	}
	return res;
}

ll fastpow(ll a, ll k, ll m)
{
	ll res = 1;
	while (k)
	{
		if (k & 1LL)
			res = (res * a) % m;
		a = (a * a) % m;
		k >>= 1LL;
	}
	return res;
}

ll slowpow(ll a, ll k, ll m)
{
	ll res = 1;
	while (k)
	{
		if (k & 1LL)
			res = russian(res, a, m);
		a = russian(a, a, m);
		k >>= 1LL;
	}
	return res;
}

ll _gcd(ll a, ll b)
{
	while (b)
		swap(a %= b, b);
	return a;
}

ll _lcm(ll a, ll b)
{
	return a / _gcd(a, b) * b;
}

ll extgcd(ll a, ll b, ll& k, ll& l)
{
	if (b == 0)
	{
		k = 1; l = 0;
		return a;
	}
	ll res = extgcd(a, a % b, l, k);
	l -= a / b * k;
	return res;
}

ll _inv(ll a, ll p)
{
	return fastpow(a, p - 2, p);
}

Measured memory_bytes: 15356