#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <cassert>
using namespace std;

void chmin(int &x,int y){x=min(x,y);}

int n,m;
vector<pair<int,int>> bomb;
vector<pair<int,int>> g[1<<17];
bool is[1<<17];
bool odd[1<<17];
vector<int> ans;

bool dfs(int v)
{
    if(is[v]) return false;
    bool res=odd[v];
    is[v]=true;
    for(auto& e:g[v])
    {
        int u,i; tie(u,i)=e;
        if(dfs(u))
        {
            ans.emplace_back(i);
            res=not res;
        }
    }
    return res;
}

int main()
{
    cin>>n>>m;
    for(int i=0;i<n;++i)
    {
        int a,b; cin>>a>>b;
        bomb.emplace_back(a,b);
    }
    bomb.emplace_back(0,0);
    bomb.emplace_back(1e9+1,0);
    sort(begin(bomb),end(bomb));
    for(int i=1;i<=m;++i)
    {
        int l,r; cin>>l>>r; ++r;
        l=lower_bound(begin(bomb),end(bomb),pair<int,int>{l,0})-begin(bomb)-1;
        r=lower_bound(begin(bomb),end(bomb),pair<int,int>{r,0})-begin(bomb)-1;
        assert(l<=n);
        assert(r<=n);
        g[l].emplace_back(r,i);
        g[r].emplace_back(l,i);
        // cerr << "edge: " << l << " " << r << "\n";
    }
    for(int i=0;i<=n;++i)
    {
        odd[i]=(bomb[i].second!=bomb[i+1].second);
    }
    for(int i=0;i<=n;++i)
    {
        if(dfs(i))
        {
            // cerr << "out at: " <<  i << "\n";
            cout << -1 << "\n";
            return 0;
        }
    }
    cout << ans.size() << "\n";
    sort(begin(ans),end(ans));
    for(auto &e:ans)
    {
        cout << e << " ";
    }
    cout << "\n";
}