import math N, M = map(int, input().split()) if M < N - 1: print('NO') exit() if N % 2 == 0: if M > (N // 2) ** 2: print('NO') exit() else: if M > (N // 2) * (N // 2 + 1): print('NO') exit() print('YES') for i in range(N): print(i + 1, end=' ') print() small = list(range(1, math.ceil(N / 2) + 1)) big = list(range(math.ceil(N / 2) + 1, N + 1)) count = 0 flg = True s = 0 b = 0 while count < M: if flg: for n in big[b:]: print(str(small[s]) + ' ' + str(n)) count += 1 if count >= M: exit() s += 1 else: for n in small[s:]: print(str(big[b]) + ' ' + str(n)) count += 1 if count >= M: exit() b += 1 flg = not(flg)