#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

struct edge{
    int from, to, id;
    edge(int from, int to, int id): from(from), to(to), id(id){}
};

int n, m, X[MAX];
pii p[MAX];
vector<edge> G[MAX];
bool used[MAX];
vector<int> ans;

void dfs(int v, edge pe){
    used[v] = true;
    for(auto &e: G[v])if(!used[e.to]) dfs(e.to, e);
    if(X[v] && pe.from != -1){
        X[v] ^= 1;
        X[pe.from] ^= 1;
        ans.push_back(pe.id);
    }
}

int main(){
    scanf("%d%d", &n, &m);
    rep(i, n) scanf("%d%d", &p[i].fi, &p[i].se);
    p[n] = {mod, 0};
    sort(p, p+n+1);
    X[0] = p[0].se;
    For(i, 1, n+1) X[i] = p[i-1].se ^ p[i].se;

    rep(i, m){
        int L, R;
        scanf("%d%d", &L, &R);
        int l = lower_bound(p, p+n+1, make_pair(L, 0)) - p;
        int r = upper_bound(p, p+n+1, make_pair(R, 1)) - p;
        if(l == r) continue;
        G[l].emplace_back(l, r, i);
        G[r].emplace_back(r, l, i);
    }

    memset(used, false, sizeof(used));
    rep(i, n+1)if(!used[i]){
        dfs(i, {-1, i, -1});
        if(X[i] == 1){
            puts("-1");
            return 0;
        }
    }

    sort(ans.begin(), ans.end());
    printf("%d\n", ans.size());
    for(int i: ans) printf("%d ", i+1);
}