#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <functional>
#include <utility>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vp;
typedef priority_queue<int, vp, greater<pii> > pqp;

void dfs(vi e[], int x, int p, int m0[], int &m0i, int sz[]) {
    m0[x] = m0i++;
    sz[x] = 1;
    for (int y : e[x]) {
        if (y != p) {
            dfs(e, y, x, m0, m0i, sz);
            sz[x] += sz[y];
        }
    }
}

void add(bool bit[], int n, int x) {
    for (; x <= n; x += x & -x) {
        bit[x] ^= 1;
    }
}

bool qry(bool bit[], int x) {
    bool r = false;
    for (; x; x -= x & -x) {
        r ^= bit[x];
    }
    return r;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int n, m;
    cin >> n >> m;
    int ta[n], tb[n];
    int x[n];
    for (int i = 0; i < n; i++) {
        cin >> ta[i] >> tb[i];
        x[i] = ta[i];
    }
    sort(x, x+n);

    int b[n];
    for (int i = 0; i < n; i++) {
        b[lower_bound(x, x+n, ta[i])-x] = tb[i];
    }

    pqp q[n+1];
    int st[m];
    for (int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;
        l = lower_bound(x, x+n, l) - x;
        r = upper_bound(x, x+n, r) - x;
        q[l].push({r, i});
        st[i] = l;
    }

    int ch[n];
    fill(ch, ch+n, -1);
    int p[n+1];
    fill(p, p+n+1, n);
    bool df[n+1];
    fill(df, df+n+1, false);
    bool f[n+1];
    fill(f, f+n+1, false);
    bool cur = false;
    for (int i = 0; i < n; i++) {
        while (!q[i].empty() && q[i].top().first == i) {
            q[i].pop();
        }

        int t, c = -1;
        if (!q[i].empty()) {
            t = q[i].top().first;
            c = q[i].top().second;
            while (!q[i].empty() && q[i].top().first == t) {
                q[i].pop();
            }

            if (q[i].size() > q[t].size()) {
                swap(q[i], q[t]);
            }

            while (!q[i].empty()) {
                pii x = q[i].top();
                q[i].pop();
                q[t].push(x);
            }

            p[i] = t;
            ch[i] = c;
        }

        cur ^= df[i];
        if (b[i] ^ cur) {
            if (c == -1) {
                cout << -1 << endl;
                return 0;
            } else {
                df[i] ^= 1;
                df[t] ^= 1;
                cur ^= 1;
                f[i] = true;
            }
        }
    }

    vi e[n+1];
    for (int i = 0; i < n; i++) {
        e[p[i]].push_back(i);
    }

    int m0[n+1];
    int m0i = 1;
    int sz[n+1];
    dfs(e, n, -1, m0, m0i, sz);

    bool bit[n+3];
    fill(bit, bit+n+3, false);
    for (int i = 0; i < n; i++) {
        if (f[i]) {
            add(bit, n + 2, m0[i]);
            add(bit, n + 2, m0[p[i]]);
        }
    }

    vi ans;
    for (int i = n - 1; i >= 0; i--) {
        if (qry(bit, m0[i] - 1) ^ qry(bit, m0[i] + sz[i] - 1)) {
            ans.push_back(ch[i]);
            add(bit, n + 1, m0[st[ch[i]]]);
            add(bit, n + 1, m0[p[i]]);
        }
    }

    sort(ans.begin(), ans.end());
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] + 1 << " \n"[i==ans.size()-1];
    }

    return 0;
}


Measured memory_bytes: 23668