#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1LL<<60;
long double pi=3.141592653589793238462643383279L;
double eps=1e-12;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
struct edge{
    int from,to,num;
};
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,m;cin>>n>>m;
    int a[n],b[n];
    vector<pii> w;
    rep(i,0,n){
        cin>>a[i]>>b[i];
        w.push_back({a[i],b[i]});
    }
    sort(w.begin(),w.end());
    vector<pii> v[n+1];
    rep(i,0,m){
        int f,g;cin>>f>>g;
        pii p={f,-1};
        int y=lower_bound(w.begin(),w.end(),p)-w.begin();
        p={g,2};
        int yy=upper_bound(w.begin(),w.end(),p)-w.begin();
        if(y==yy)continue;
        v[y].push_back({yy,i});
        v[yy].push_back({y,i});
    }
    int mo[n+1];
    if(w[0].second==0)mo[0]=0;
    else mo[0]=1;
    rep(i,1,n){
        if(w[i-1].second!=w[i].second)mo[i]=1;
        else mo[i]=0;
    }
    mo[n]=-1;
    bool used[n+1];
    fill(used,used+n+1,false);
    vector<int> ans;
    vector<pii> vv[n+1];
    int par[n+1];
    int cnt[n+1];
    fill(cnt,cnt+n+1,0);
    int dp[n+1];
    fill(dp,dp+n+1,0);
    int pan[n+1];
    /*rep(i,0,n+1){
        rep(j,0,v[i].size())cout<<v[i][j].first<<" ";
        cout<<endl;
    }*/
    rep(i,0,n){
        if(used[i])continue;
        queue<int> q;
        q.push(i);
        used[i]=true;
        int y=0;
        while(q.size()>0){
            int now=q.front();q.pop();
            if(now==n)y=1;
            rep(j,0,v[now].size()){
                int ne=v[now][j].first,num=v[now][j].second;
                if(used[ne])continue;
                used[ne]=true;
                vv[now].push_back({ne,num});
                vv[ne].push_back({now,num});
                q.push(ne);
            }
        }
        int roo=i;
        if(y)roo=n;
        q.push(roo);
        par[roo]=n+2;
        vv[roo].push_back({n+2,-1});
        queue<int> qq;
        while(q.size()>0){
            int now=q.front();q.pop();
            if(vv[now].size()==1)qq.push(now);
            rep(j,0,vv[now].size()){
                int ne=vv[now][j].first;
                if(par[now]==ne)continue;
                par[ne]=now;
                q.push(ne);
                pan[ne]=vv[now][j].second;
            }
        }
        while(qq.size()>0){
            int now=qq.front();qq.pop();
            if(mo[now]==1)dp[now]^=1;
            if(now==roo)break;
            int pp=par[now];
            if(dp[now]==1)ans.push_back(pan[now]);
            dp[pp]^=dp[now];
            cnt[pp]++;
            if(cnt[pp]==vv[pp].size()-1)qq.push(pp);
        }
        /*if(roo==n){
            rep(j,0,vv[roo].size()){
                int ne=vv[roo][j].first,num=vv[roo][j].second;
                if(dp[ne]==1)ans.push_back(num);
            }
            continue;
        }*/
        if(roo!=n&&dp[roo]==1){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans.size()<<endl;
    sort(ans.begin(),ans.end());
    rep(i,0,ans.size())cout<<ans[i]+1<<" ";
    cout<<endl;
}




Measured memory_bytes: 19060