#int(input()) #map(int, input().split()) #list(map(int, input().split())) N, M = map(int, input().split()) a, b = divmod(N, 2) if M < N-1 or M > a*(a+b): print("NO") exit() else: print("YES") a = [0] * N for i in range(N): a[i] = (i % 2) + 1 print(" ".join([str(_) for _ in a])) s = set() for i in range(N-1): s.add((i, i+1)) M -= N-1 c = 0 while M: c += 1 u, v = divmod(c, N) if u >= v: continue if (u+v) % 2 == 0: continue if (u, v) not in s: M -= 1 s.add((u, v)) for x in s: print(x[0]+1, x[1]+1)