#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

// #define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << " "
#define dumpL(x) cout << #x << " : " << x << '\n'
#define LINE cout << "line : " << __LINE__ << " "
#define LINEL cout << "line : " << __LINE__ << '\n'
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << " "
#define dumpVL(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) 
#define dumpL(x) 
#define LINE 
#define LINEL 
#define dumpV(v) 
#define dumpVL(v) 
#define STOP assert(false)
#endif
#define mp make_pair
 
namespace std {
template<class S, class T>
ostream &operator <<(ostream& out, const pair<S, T>& a) {
    out << '(' << a.fi << ", " << a.se << ')';
    return out;
}
}

struct UF{ //O(loga(n))
    int n;
    int m;
    vi d, r;
    UF(int n) : n(n), m(n), d(n, -1), r(n, 0){};
    int root(int i){
        if(d[i] < 0) return i;
        return d[i] = root(d[i]);
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    bool unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return false;

        if(r[x] < r[y]) swap(x, y);
        else if(r[x] == r[y]) r[x]++;
        d[x] += d[y];
        d[y] = x;
        --m;
        return true;
    }
    int size(int i){
        return -d[root(i)];
    }
    int size() {
        return m;
    }
};

int main(){
    int n, m;
    cin >> n >> m;
    vi A(n+2), B(n+2);
    A.front() = 0;
    A.back() = 1e9+10;
    {
        vector<pii> p(n);
        rep(i, n) cin >> p[i].fi >> p[i].se;
        sort(all(p));
        rep(i, n) {
            A[i+1] = p[i].fi;
            B[i+1] = p[i].se;
        }
    }
    vi L(m), R(m);
    rep(i, m) cin >> L[i] >> R[i];
    vi d(n+1);
    rep(i, n+1) {
        d[i] = B[i]^B[i+1];
    }
    UF uf(n+1);
    vector<vector<pii>> es(n+1);
    rep(i, m) {
        int s = lower_bound(all(A), L[i]) - A.begin();
        int t = upper_bound(all(A), R[i]) - A.begin();
        t--;
        // dump(L[i]);dump(R[i]);dump(s); dumpL(t);
        if(s > t) {
            // rep(i, A.size()) cout << " " << A[i];
            // cout << endl;
            // cout << i << ": " << L[i] << " -> " << R[i] << " = " << s << " -> " << t << endl;
            continue;
        }
        // assert(s <= t);
        dump(L[i]); dump(R[i]); dump(s); dumpL(t);
        --s;
        if(uf.same(s, t)) continue;
        uf.unite(s, t);
        es[s].pb({t, i});
        es[t].pb({s, i});
    }
    vector<int> used(n+1);
    vector<int> dp(n+1);
    vector<int> path;
    function<int(int, int)> dfs = [&](int cur, int par) {
        // cout << "In: ";
        dump(cur);dumpL(par);
        if(used[cur]) return dp[cur];
        used[cur] = true;
        auto& ret = dp[cur];
        ret = d[cur];
        // if(ret) ret |= 2;
        for(auto&& e: es[cur]) {
            auto to = e.fi;
            auto id = e.se;
            if(to == par) continue;
            int tmp = dfs(to, cur);
            if(tmp&1) path.pb(id);
            dumpVL(path);
            // ret ^= (tmp&1);
            ret ^= tmp;
            dump(cur);dump(to);dump(id);dump(tmp);dumpL(ret);
        }
        // cout << "Out: ";
        dump(cur);dumpL(ret);
        return ret;
    };
    dumpVL(A);
    dumpVL(B);
    dumpVL(d);
    for(auto&& v: es) {
        dumpVL(v);
    }
    rep(i, n+1) {
        if(used[i]) continue;
        if(d[i] == 0) continue;
        dumpL(i);
        auto tmp = dfs(i, -1);
        if(tmp&1) {
            cout << -1 << endl;
            return 0;
        }
    }
    sort(all(path));
    cout << path.size() << endl;
    rep(i, path.size()) {
        cout << path[i]+1 << (i+1 == (int)path.size() ? '\n' : ' ');
    }
    return 0;
}

Measured memory_bytes: 11376