### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))

N, M = map(int, input().split())
R = []
for _ in range(N):
    a, b = map(int, input().split())
    R.append((a*2, b, 0, 0))
for i in range(M):
    l, r = map(int, input().split())
    R.append((l*2-1, 2, -1, i))
    R.append((r*2+1, 3, 2*l-1, i))

R.sort(key=lambda x:x[0])
nodeid = 0
bf = -1
d = dict()
x2id = dict()
id2eid = dict()
G = [set()]
for x, f, l, i in R:
    if f <= 1:
        d[nodeid] = int(f != bf and bf != -1)
        bf = f
        nodeid += 1
        G.append(set())
    else:
        x2id[x] = nodeid
        if f == 3:
#            print(x2id, l)
            G[nodeid].add(x2id[l])
            G[x2id[l]].add(nodeid)
            id2eid[(nodeid, x2id[l])] = i
            id2eid[(x2id[l], nodeid)] = i
d[nodeid] = int(bf == 1)

def iterf(v):
    r = d[v]
    for u in G[v]:
        if u in vs:
            continue
        vs.add(u)
        ff = iterf(u)
        if ff:
            cut_edges.add((v, u))
        r = (r+ff)%2
    return r if v != 0 else 0

xxs = [-1]*(nodeid+1)
g2 = [set() for _ in range(nodeid+1)]
vs = set()
cut_edges = set()
for i in range(nodeid+1):
    if i in vs:
        continue
    stack = [i]
    dfs_vs = []
    vs.add(i)
    while stack:
        v = stack.pop()
        dfs_vs.append(v)
        for u in G[v]:
            if u in vs:
                continue
            g2[v].add(u)
#            g2[u].add(v)
            stack.append(u)
            vs.add(u)
#    print(G)
#    print(g2)
#    print(dfs_vs)
#    print(d)
    for v in dfs_vs[::-1]:
#        print(v, d[v])
        r = d[v]
        for u in g2[v]:
            ff = xxs[u]
            if ff:
                cut_edges.add((v, u))
            r = (r+ff)%2
        xxs[v] = r if v != 0 else 0
#    print(xxs)
    if xxs[i]:
        print(-1)
        break
else:
    print(len(cut_edges))
    print(*sorted(id2eid[(x, y)]+1 for x, y in cut_edges))


### FIXED CODE ###

import sys
input = sys.stdin.readline
LLL = 1<<20

N, M = map(int, input().split())
R = []
for _ in range(N):
    a, b = map(int, input().split())
    R.append((a*2, b, 0))
for i in range(M):
    l, r = map(int, input().split())
    R.append((l*2-1, 2, i))
    R.append((r*2+1, 3, i))

R.sort(key=lambda x:x[0])
nodeid = 0
bf = -1
d = []
eid2lid = dict()
id2eid = dict()
G = [set()]
for x, f, i in R:
    if f <= 1:
        d.append(int(f != bf and bf != -1))
        bf = f
        nodeid += 1
        G.append(set())
    else:
        if f == 3:
#            print(x2id, l)
            lid = eid2lid[i]
            if nodeid != lid:
                G[nodeid].add((lid, i+1))
                G[lid].add((nodeid, i+1))
#                id2eid[lid*LLL+nodeid] = i
#            id2eid[(n2, n1)] = i
        eid2lid[i] = nodeid
d.append(int(bf==1))

xxs = [-1]*(nodeid+1)
g2 = [set() for _ in range(nodeid+1)]
vs = set()
cut_edges = set()
for i in range(nodeid+1):
    if i in vs:
        continue
    stack = [i]
    dfs_vs = []
    vs.add(i)
    while stack:
        v = stack.pop()
        dfs_vs.append(v)
        for u, j in G[v]:
            if u in vs:
                continue
            g2[v].add((u, j))
            stack.append(u)
            vs.add(u)
    for v in dfs_vs[::-1]:
        r = d[v]
        for u, j in g2[v]:
            ff = xxs[u]
            if ff:
                cut_edges.add(j)
            r = (r+ff)%2
        xxs[v] = r if v != 0 else 0
    if xxs[i]:
        print(-1)
        break
else:
    print(len(cut_edges))
    print(*sorted(cut_edges))