#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

#define lc c[x][0]
#define rc c[x][1]

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-8;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 1e5+10;
const int MAXM = (int) 3e6+10;

///--------------------START-------------------------
int M,N;
int a[MAXN],b[MAXN],s[MAXN];
pair<int,int> aa[MAXN];
int p[MAXN],mark[MAXN],siz[MAXN];
vector<int> ans;

struct Edge{
    int u,v;
    int id;
    int next;
}edge[MAXN<<1];
int edgenum,head[MAXN];

void addEdge(int u,int v,int id){
    edge[edgenum].u=u;
    edge[edgenum].v=v;
    edge[edgenum].id=id;
    edge[edgenum].next=head[u];
    head[u]=edgenum++;
}

int Find(int x){
    return p[x]==x?x:p[x]=Find(p[x]);
}

void Merge(int u,int v,int id){
    int x=Find(u);
    int y=Find(v);
    if(x!=y){
        p[x]=y;
        addEdge(u,v,id);
        addEdge(v,u,id);
        mark[u]=1;
        mark[v]=1;
//        printf("addEdge %d %d : %d\n",u,v,id);
    }
}

void DFS(int u,int fa){
    siz[u]+=s[u];
    mark[u]=1;
    for(int i=head[u];~i;i=edge[i].next){
        int v=edge[i].v;
        int id=edge[i].id;
        if(v==fa) continue;
        DFS(v,u);
        siz[u]+=siz[v];
        if(siz[v]&1) ans.push_back(id);
    }
}

void work(){
    scanf("%d",&N);
    scanf("%d",&M);
    for(int i=1;i<=N;i++){
        scanf("%d%d",&aa[i].first,&aa[i].second);
    }
    sort(aa+1,aa+1+N);
    for(int i=1;i<=N;i++){
        a[i]=aa[i].first;
        b[i]=aa[i].second;
        s[i]=b[i]^b[i-1];
    }
//    printf("=== a ===\n");
//    for(int i=1;i<=N;i++) printf("%d ",a[i]);
//    printf("\n");
//    printf("=== b ===\n");
//    for(int i=1;i<=N;i++) printf("%d ",b[i]);
//    printf("\n");

    a[N+1]=INF;
    for(int i=1;i<=N+1;i++) p[i]=i;
    memset(head,-1,sizeof(head));
    edgenum=0;
    int totcnt=0,cnt=0;
    for(int i=1;i<=N;i++){
        if(s[i]==1) totcnt++;
    }
    if(totcnt&1){
        s[N+1]=1;
        totcnt++;
    }
    else b[N+1]=0;

    for(int i=1;i<=M;i++){
        int l,r; scanf("%d%d",&l,&r);
        if(r<a[1]||l>a[N]) continue;
        int L=lower_bound(a+1,a+1+N,l)-a;
        int R=upper_bound(a+1,a+1+N,r)-a;
//        printf("l = %d , r = %d , L = %d ,R = %d\n",l,r,L,R);
        Merge(L,R,i);
    }
    for(int i=1;i<=N+1;i++){
        if(s[i]==1&&mark[i]) cnt++;
    }
//    printf("totcnt = %d , cnt = %d\n",totcnt,cnt);
    if(totcnt>cnt){
        printf("-1\n");
        return;
    }
    if(cnt&1){
        printf("-1\n");
        return;
    }
    int ok=1;
    memset(mark,0,sizeof(mark));
    for(int i=1;i<=N+1;i++)if(!mark[i]){
        DFS(i,-1);
        if(siz[i]&1){
            ok=0;
            break;
        }
    }
    sort(ans.begin(),ans.end());
    int anssiz=ans.size();
    if(!ok){
        printf("-1\n");
        return;
    }
    printf("%d\n",anssiz);
    for(int i=0;i<anssiz;i++){
        printf("%d",ans[i]);
        if(i<anssiz-1) printf(" ");
    }
    printf("\n");
}
/*
4 2
1 1
2 1
3 0
4 0
1 2
3 4
*/

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}






Measured memory_bytes: 8320