#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}
#define int long long
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int > > > pq[100010];
signed main(){
    int n,m;
    cin >> n >> m;
    vector<pair<int,int> >a;
    rep(i,n){
        int s,t;
        cin >> s >> t;
        a.push_back(MP(s,t));
    }
    sort(a.begin(),a.end());
    vector<int> l(m),r(m);
    rep(i,m){
        int s,t;
        cin >> s >> t;
        l[i] = lower_bound(a.begin(),a.end(),MP(s,(ll)0))-a.begin();
        r[i] = upper_bound(a.begin(),a.end(),MP(t,(ll)1))-a.begin();
    }
    rep(i,m){
        if(l[i]<r[i])pq[l[i]].push(MP(r[i],i));
    }
    vector<pair<int,int> > c(m);
    int tt = m;
    vector<int> res(n);
    rep(i,n){
        res[i] = a[i].second;
    }
    int cc = 0;
    vector<int> imos(n+1);
    vector<int> gg(m);
    rep(i,n){
        cc += imos[i];
        if(cc%2==1){
            res[i] = 1-res[i];
        }
        pair<int,int> st;
        pair<int,int> pre;
        bool f = 1;
        while(!pq[i].empty()){
            auto x = pq[i].top();
            pq[i].pop();
            if(f){
                st = x;
                pre = x;
                f = 0;
            }else{
                if(pre.first!=x.first){
                    c.push_back(MP(pre.second,x.second));
                    gg.push_back(0);
                    pq[pre.first].push(MP(x.first,tt));
                    tt++;
                }
                pre = x;
            }
        }
        if(f)continue;
        if(res[i]==0)continue;
        gg[st.second]++;
        cc++;
        imos[st.first]--;   
        res[i] = 0;
    }
    
    rep(i,n){
        if(res[i]==1){
            cout << -1 << endl;
            return 0;
        }
    }
    // rep(i,tt){
    //     cerr << gg[i] << " ";
    // }
    // cerr << endl;
    for(int i=tt-1;i>=m;i--){
        int s = c[i].first;
        int p = c[i].second;
        // cerr << i << " " << s << " " << p << endl;
        
        gg[s] += gg[i];
        gg[s] %= 2;
        gg[p] += gg[i];
        gg[p] %= 2;
    }
    vector<int> ans;
    rep(i,m){
        if(gg[i]%2==1){
            ans.push_back(i);
        }
    }
    cout << ans.size() << endl;
    for(auto xx:ans){
        cout << xx+1 << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 77272