#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
    int N, M;
    cin>>N>>M;
    vector<int> A(N), B(N);
    for (int i=0; i<N;i++)
        cin>>A[i]>>B[i];
    vector<int> L(M), R(M);
    for (int i=0; i<M; i++)
        cin>>L[i]>>R[i];

    vector<pair<int, int>> AB(N);
    for (int i=0; i<N; i++)
        AB[i] = make_pair(A[i], B[i]);
    sort(AB.begin(), AB.end());
    for (int i=0; i<N; i++)
        A[i] = AB[i].first,
        B[i] = AB[i].second;

    A.push_back(1000000001);
    B.push_back(0);
    vector<int> C(N+1);
    C[0] = B[0];
    for (int i=1; i<=N; i++)
        C[i] = B[i-1]^B[i];

    vector<vector<int>> E(N+1);
    vector<vector<int>> EI(N+1);
    for (int i=0; i<M; i++)
    {
        int x = int(lower_bound(A.begin(), A.end(), L[i])-A.begin());
        int y = int(lower_bound(A.begin(), A.end(), R[i]+1)-A.begin());
        E[x].push_back(y);
        EI[x].push_back(i);
        E[y].push_back(x);
        EI[y].push_back(i);
    }

    vector<bool> V(N+1);
    vector<int> ans;

    function<int (int)> f = [&](int p)
    {
        if (V[p])
            return 0;
        V[p] = true;

        int s = C[p];
        for (int i=0; i<(int)E[p].size(); i++)
            if (f(E[p][i]) != 0)
            {
                ans.push_back(EI[p][i]);
                s ^= 1;
            }
        return s;
    };

    for (int r=0; r<=N; r++)
        if (!V[r])
            if (f(r)!=0)
            {
                cout<<-1<<endl;
                return 0;
            }
    
    sort(ans.begin(), ans.end());
    cout<<ans.size()<<endl;
    for (int i=0; i<(int)ans.size(); i++)
        cout<<(i==0 ? "" : " ")<<ans[i]+1;
    cout<<endl;
}
