### BUGGY CODE ###

import os
import sys

import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import connected_components

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


# 解説
N, M = list(map(int, sys.stdin.buffer.readline().split()))
AB = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(N)]
LR = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(M)]
AB = np.array(AB, dtype=int)
LR = np.array(LR, dtype=int)

AB = AB[np.argsort(AB[:, 0])]
A, B = AB[:, 0], AB[:, 1]
L, R = LR[:, 0], LR[:, 1]

L = np.searchsorted(A, L, side='left').tolist()
R = np.searchsorted(A, R, side='right').tolist()

# L か R の数が奇数になる場所が True
is_odd = np.diff(np.concatenate(([0], B, [0]))) != 0

G = csr_matrix(([1] * M, (L, R)), shape=(N + 1, N + 1))
_, components = connected_components(G, directed=False)

graph = [[] for _ in range(N + 1)]
for i, (l, r) in enumerate(list(zip(L, R))):
    graph[l].append((r, i))
    graph[r].append((l, i))

counts = [0] * (N + 1)
for i, g in enumerate(components):
    counts[g] += is_odd[i]

# 奇数の連結成分がある
if np.any(np.array(counts) % 2 == 1):
    print(-1)
    exit()

ans = []
seen_graph = [False] * (N + 1)
seen_v = [False] * (N + 1)
parents = [None] * (N + 1)


def dfs(v):
    # 子の is_odd の数が奇数ならその辺を切る。葉からやってけば root で辻褄が合う
    ret = int(is_odd[v])
    for u, j in graph[v]:
        if seen_v[u]:
            continue
        seen_v[u] = True
        children_odds = dfs(u)
        if children_odds % 2 == 1:
            ans.append(j)
        ret += children_odds
    return ret


for v in range(N + 1):
    if seen_graph[components[v]]:
        continue
    seen_graph[components[v]] = True
    seen_v[v] = True
    dfs(v)


ans = np.array(ans, dtype=int)
ans.sort()
print(len(ans))
print(*(ans + 1))


### FIXED CODE ###

import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


# 解説
N, M = list(map(int, sys.stdin.buffer.readline().split()))
AB = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(N)]
LR = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(M)]
AB = np.array(AB, dtype=int)
LR = np.array(LR, dtype=int)

AB = AB[np.argsort(AB[:, 0])]
A, B = AB[:, 0], AB[:, 1]
L, R = LR[:, 0], LR[:, 1]

L = np.searchsorted(A, L, side='left').tolist()
R = np.searchsorted(A, R, side='right').tolist()

# L か R の数が奇数になる場所が True
is_odd = np.diff(np.concatenate(([0], B, [0]))) != 0

graph = [[] for _ in range(N + 1)]
for i, (l, r) in enumerate(list(zip(L, R))):
    graph[l].append((r, i))
    graph[r].append((l, i))

seen_graph = [False] * (N + 1)
seen_v = [False] * (N + 1)
parents = [None] * (N + 1)


def dfs(v):
    # 子の is_odd の数が奇数ならその辺を切る。葉からやってけば root で辻褄が合う
    ret = int(is_odd[v])
    for u, j in graph[v]:
        if seen_v[u]:
            continue
        seen_v[u] = True
        children_odds = dfs(u)
        if children_odds % 2 == 1:
            ans.append(j)
        ret += children_odds
    return ret


ans = []
for v in range(N + 1):
    if seen_v[v]:
        continue
    seen_v[v] = True
    if dfs(v) % 2 != 0:
        print(-1)
        exit()

ans = np.array(ans, dtype=int)
ans.sort()
print(len(ans))
print(*(ans + 1))