#include<bits/stdc++.h>
#define nguyendz the_best

#define all(n) n.begin(),n.end()
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define pll pair<ll,ll>
#define YES cout <<"YES"<<endl;
#define NO cout <<"NO"<<endl;
#define ff first
#define ss second
//#define ((x|y)-y) (x&(~y))
//#define gcd(fibo(x),fibo(y)) = fibo(gcd(x,y))
using namespace std;
const ll maxn=3e5+1;
const ll maxx=1e13;
const ll mod=1e9+7;
const ll mod1=998244353;

vector <pll> adj[maxn];
set<ll> adj1[maxn];
//vector<ll> ans;
//bool kt[maxn];
pll a[maxn];
pll p[maxn];
ll dd[maxn] ;
vector<ll> ans;
ll dfs(ll u)
{
    dd[u]=1;
    for (auto p:adj[u])
    {
        if (!dd[p.ff])
        {
            ll kt=dfs(p.ff);
            if (kt)
            {
                ans.pb(p.ss);
            }
           a[u].ss+=kt;
		   a[u].ss%=2;
        }
    }
    return a[u].ss;
}

int main()
{
    // freopen("test.txt","r",stdin);
    // freopen("CHEMIST.OUT","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,m;
    cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>a[i].ff>>a[i].ss;
	sort(a+1,a+n+1);

	for(int i=0;i<=n;i++)
    {

		a[i].ss+=a[i+1].ss;
		a[i].ss%=2;
    }
	for(int i=1;i<=m;i++)
	{
		cin>>p[i].ff>>p[i].ss;
		ll t1=p[i].ff;
		ll t2=p[i].ss;
		p[i].ff=(lower_bound(a+1,a+n+1,make_pair(p[i].ff,0ll))-a)-1;
		//nho hon =
		p[i].ss=(upper_bound(a+1,a+n+1,make_pair(p[i].ss,1ll))-a)-1;
		// nho hon han
	//	cout <<t1<<" "<<t2<<" "<<p[i].ff<<" "<<p[i].ss<<endl;
		adj[p[i].ff].pb(make_pair(p[i].ss,i));
		adj[p[i].ss].pb(make_pair(p[i].ff,i));
	}
	for (int i=0;i<=n;i++)
    {
        if (!dd[i])
        {

            if (dfs(i))
            {
                cout <<-1;
                return 0;
            }
        }
    }
    cout <<ans.size()<<endl;
    sort(all(ans));
    for (auto p:ans)
    {
        cout <<p<<" ";
    }

}
