### BUGGY CODE ###

import sys
input = sys.stdin.readline

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]
            G[nodeid].add(lid)
            G[lid].add(nodeid)
            if nodeid != lid:
                id2eid[lid*10**6+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 in G[v]:
            if u in vs:
                continue
            g2[v].add(u)
            stack.append(u)
            vs.add(u)
    for v in dfs_vs[::-1]:
        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
    if xxs[i]:
        print(-1)
        break
else:
    print(len(cut_edges))
    print(*sorted(id2eid[min(x, y)*10**6+max(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))