#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;


vector<P> bomb;
vector<P> edge[220000];
Int onecnt[220000];
vector<Int> ans;
bool come[110000];

void dfs(Int x){
    come[x] = true;
    onecnt[x] += bomb[x].second;
    for(auto p:edge[x]){
        Int to =p.first;
        Int ind =p.second;
        if(come[to])continue;
        dfs(to);
        onecnt[x] += onecnt[to];
        if(onecnt[to] % 2)ans.push_back(ind);
    }
//    cout << x << ": " << onecnt[x] << endl;
}



int main(){
    Int n, m;
    cin >> n >> m;
    for(Int i = 0;i < n;i++){
        Int a, b;
        cin >> a >> b;
        bomb.emplace_back(a, b);
    }
    bomb.push_back(P(LINF, 0));
    n++;
    sort(bomb.begin(), bomb.end());
    for(Int i = n-1;i > 0;i--){
        bomb[i].second ^= bomb[i-1].second;
    }

    for(Int i = 0;i < m;i++){
        Int l, r;
        cin >> l >> r;
        Int lind = lower_bound(bomb.begin(), bomb.end(), P(l, 0)) - bomb.begin();
        Int rind = upper_bound(bomb.begin(), bomb.end(), P(r, 1)) - bomb.begin();
        edge[lind].push_back(P(rind, i));
        edge[rind].push_back(P(lind, i));
//        cout << lind << " " << rind << endl;
    }

    for(Int i = 0;i < n;i++){
        if(come[i])continue;
        dfs(i);
        if(onecnt[i] % 2){
            cout << -1 << endl;
            return 0;
        }
    }

    sort(ans.begin(), ans.end());
    cout << ans.size() << endl;
    for(Int c:ans){
        cout << c+1 << " ";
    }cout << endl;
    
    return 0;
}