from collections import deque def bfs(s): q = deque([]) q.append((s, 1)) while q: v, c = q.popleft() for nv in adj_list[v]: if color[nv]==-1: color[nv] = -c q.append((nv, color[nv])) else: if color[nv]==c: return False return True N, M = map(int, input().split()) LR = [tuple(map(int, input().split())) for _ in range(N)] adj_list = [[] for _ in range(N)] for i in range(N): Li, Ri = LR[i] for j in range(i+1, N): Lj, Rj = LR[j] a, b, c, d = Li, Ri, Lj, Rj if a>c: a, b, c, d = c, d, a, b if not bc: a, b, c, d = c, d, a, b if not b