#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct Graph {
    struct Vertex { int n, v, b; };
    struct Edge { int i, n, c; };
    Graph(int n, int m) : v(n, { -1, 0, 0 }), e(m), n(n), m(0) {}
    void add_edge(int i, int j, int c) {
        e[m] = { j, v[i].n, c };
        v[i].n = m;
        m++;
    }
    int dfs(int i) {
        if (v[i].v) return 0;
        v[i].v = 1;
        int b = v[i].b;

        for (int j = v[i].n; j >= 0; j = e[j].n) {
            Edge& o = e[j];
            if (dfs(o.i)) {
                c.push_back(o.c);
                b ^= 1;
            }
        }
        return b;
    }
    void solve() {
        for (int i = 0; i < n; i++) {
            if (dfs(i)) {
                cout << -1 << endl;
                exit(0);
            }
        }

        sort(c.begin(), c.end());

        int k = c.size();
        cout << k << '\n';
        for (int i = 0; i < k; i++) {
            cout << c[i] + 1 << " \n"[i == k - 1];
        }
    }
    vector<Vertex> v;
    vector<Edge> e;
    vector<int> c;
    int n, m;
};

struct P {
    bool operator<(const P& p) const {
        return a < p.a;
    }
    int a, b;
};

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

    int n, m;
    cin >> n >> m;

    vector<P> p(n);
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;

        p[i] = { a, b };
    }
    sort(p.begin(), p.end());

    Graph g(n + 1, m * 2);
    for (int c = 0; c < m; c++) {
        int l, r;
        cin >> l >> r;
        r++;

        l = lower_bound(p.begin(), p.end(), P{ l, 0 }) - p.begin();
        r = lower_bound(p.begin(), p.end(), P{ r, 0 }) - p.begin();
        if (l == r) continue;

        g.add_edge(l, r, c);
        g.add_edge(r, l, c);
    }

    int b = 0;
    for (int i = 0; i < n; i++) {
        g.v[i].b = b ^ p[i].b;
        b = p[i].b;
    }
    g.v[n].b = b ^ 0;

    g.solve();

    return 0;
}