#!/usr/bin/env python3.8 # %% import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np from operator import itemgetter # %% N, M = map(int, readline().split()) m = map(int, read().split()) LR = zip(m, m) # %% def solve(N, M, LR): blocks = [] for L, R in LR: L1, R1 = M - 1 - R, M - 1 - L if L < L1: blocks.append((L, R)) else: blocks.append((L1, R1)) blocks.sort(key=itemgetter(0)) A = np.zeros(M, np.int64) for L, R in blocks: if A[L: R + 1].any(): A = A[::-1] if A[L: R + 1].any(): return False A[L: R + 1] = 1 return True # %% print('YES' if solve(N, M, LR) else 'NO')