n,m = map(int,input().split()) if m+1 < n or n//2*(n-n//2) < m: print("NO") exit() print("YES") a = list(range(1,n+1)) for i in range(n//2): print(i+1,n//2+1) m -= 1 while True: for i in range(n//2): for j in range(n//2+1,n): if m == 0: exit() print(i+1,j+1) m -= 1