#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

long long min(long long a, long long b) {return a < b ? a : b;}
long long min(int a, long long b) {return a < b ? a : b;}
long long min(long long a, int b) {return a < b ? a : b;}
long long min(int a, int b) {return a < b ? a : b;}

long long max(long long a, long long b) {return a > b ? a : b;}
long long max(int a, long long b) {return a > b ? a : b;}
long long max(long long a, int b) {return a > b ? a : b;}
long long max(int a, int b) {return a > b ? a : b;}

#define int long long

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

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

const long long INF = 1e18;
const int N = 210110;
const int MOD = 1e9 + 7;
const double eps = 1e-8;

int n, m;
int root[N], sz[N];
pair<int, int> ab[N], lr[N];
vector<pii> graph[N];
int ch[N], c[N], si[N];
vector<int> ans;

int Root(int x)
{
    if (x == root[x]) return x;
    return root[x] = Root(root[x]);
}

int Merge(int v, int u, int id)
{
    int x = Root(v), y = Root(u);
    if (x == y) return 0;
    if (sz[x] < sz[y])
    {
        sz[y] += sz[x];
        root[x] = y;
    }
    else
    {
        sz[x] += sz[y];
        root[y] = x;
    }
    graph[v].push_back({u, id});
    graph[u].push_back({v, id});
    return 1;
}

void dfs(int v, int id)
{
    c[v] = 1;
    si[v] = ch[v];
    for (auto ui : graph[v])
    {
        int u = ui.first, i = ui.second;
        if (c[u] == 0)
        {
            dfs(u, i);
            si[v] += si[u];
        }
    }
    if (si[v] % 2 == 0)
    {
        return;
    }
    else
    {
        if (id == -1) cout << -1, exit(0);
        ans.push_back(id + 1);
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i <= n; i++) root[i] = i, sz[i] = 1;
    for (int i = 0; i < n; i++)
    {
        cin >> ab[i].first >> ab[i].second;
    }
    for (int i = 0; i < m; i++)
    {
        cin >> lr[i].first >> lr[i].second;
        lr[i].first--;
    }
    ab[n] = {-11, 0};
    n++;
    sort(ab, ab + n);
    for (int i = 0; i < m; i++)
    {
        int l = -1, r = n;
        while (l + 1 < r)
        {
            int m = (l + r) / 2;
            if (ab[m].first <= lr[i].first)
            {
                l = m;
            }
            else
            {
                r = m;
            }
        }
        lr[i].first = l;
        l = -1, r = n;
        while (l + 1 < r)
        {
            int m = (l + r) / 2;
            if (ab[m].first <= lr[i].second)
            {
                l = m;
            }
            else
            {
                r = m;
            }
        }
        lr[i].second = l;
    }
    for (int i = 0; i < m; i++)
    {
        Merge(lr[i].first, lr[i].second, i);
    }
    for (int i = 0; i < n; i++)
    {
        ch[i] = ab[i].second != ab[i + 1].second;
    }
    for (int i = 0; i < n; i++)
    {
        if (c[i] == 0)
        {
            dfs(i, -1);
        }
    }
    sort(all(ans));
    cout << ans.size() << "\n";
    for (auto e : ans) cout << e << " ";
}


Measured memory_bytes: 24444