#include <bits/stdc++.h>
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a,v) memset(a, v, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1e9+7;
const int N=2e5+5;
pair<int,int> a[N];int n,m;
int d[N];     
vector<pair<int,int> > g[N];   
int visit[N];
vector<int> ans;
int f=1;
void dfs(int i,int p,int ind){

    visit[i]=1;
    for(auto j:g[i]){
        if(visit[j.fst])continue;
        dfs(j.fst,i,j.snd);
    }
    if(p!=-1){
        if(d[i]==1){
            ans.pb(ind);d[i]=0;
            d[p]^=1;
        }
    }
    else{
        if(d[i]==1){
            f=0;
        }
    }
    return ;
}
int main() {
  
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
        cin>>n>>m;
        rep(i,n)cin>>a[i+1].fst>>a[i+1].snd;
        sort(a+1,a+n+1);
        a[n+1]={1e9+1,0};
        d[0]=0;
        repA(i,1,n+1)d[i]=a[i].snd^a[i-1].snd;
        vector<int> v(n+2,0);
        repA(i,1,n+1)v[i]=a[i].fst;
        rep(i,m){
            int l,r;cin>>l>>r;
            r++;
            int x=lower_bound(v.begin(),v.end(),l)-v.begin();
            if(x<=(n)){
                // dbg(r);?
                int y=lower_bound(v.begin(),v.end(),r)-v.begin();
                g[x].pb({y,i});
                g[y].pb({x,i});
                // dbg(x,y);
            }
        }
        for(int i=1;i<=n;i++){
            if(visit[i]==0){
                dfs(i,-1,-1);
            }
        }
        if(f){
            sort(all(ans));
            cout<<sz(ans)<<endl;
            for(auto j:ans)cout<<j+1<<" ";
        }
        else{
            cout<<-1;
        }
    }   
    timecalculater();
    return 0;   
} 

Measured memory_bytes: 18556