// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()

using LL = long long;
int vis[100005];
int n,m;
vector <int> ans;

#define mp(x,y) make_pair(x,y)

using P = pair<int,int> ;
vector<pair<int,int> > g[100005];
int a[100005];
bool b[100005];
vector <int> lsh;
void dfs(int x)
{
	vis[x]=1;
	for(auto u:g[x])
	{
		if(vis[u.first]) continue;
		dfs(u.first);
		if(b[u.first])
		{
			ans.push_back(u.second);
			b[u.first]^=1;
			b[x]^=1;
		}
	}
}

int main() {
    ios_base::sync_with_stdio(false);
	cin>>n>>m;
	vector <pair<int,int> > psort;
//	psort.reserve(n);
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
		psort.push_back(mp(a[i],b[i]));
		lsh.push_back(a[i]);
	}
	sort(all(psort));
	for(int i=0;i<n;i++)
	{
		a[i]=psort[i].first;
		b[i]=psort[i].second;
	}
	for(int i=n;i>=0;i--)
	{
		b[i]^=(i?b[i-1]:0);
	}
	sort(all(lsh));
    for (int i = 0; i < m; ++i) {
    	int l,r;
		cin>>l>>r;
		l=lower_bound(all(lsh),l)-lsh.begin();
		r=upper_bound(all(lsh),r)-lsh.begin();
		g[l].push_back(make_pair(r,i));
		g[r].push_back(make_pair(l,i));
    }
	for(int i=0;i<=n;i++)
	{
		if(vis[i]) continue;
		dfs(i);
		if(b[i])
		{
			cout<<-1<<endl;
			return 0;
		}
	}
	sort(all(ans));
	cout<<ans.size()<<endl;
	for(auto x:ans)
	{
		cout<<x+1<<' ';
	}
	cout<<endl;
    return 0;
}
