N,K=map(int,input().split()) if N==K==1: print("Yes") print(1) exit() if N*(N+1)//2%K!=0: print("No") else: ANS=[[0]*(N//K) for i in range(K)] rest=N//K col=0 if rest%2==1: start=0 for j in range(3): for i in range(K): ANS[(i+start)%K][j]=1+i+j*K start+=1 col+=3 for i in range(K): for j in range(col,rest): if j%2==0: ANS[i][j]=1+i+j*K else: ANS[i][j]=K-i+j*K print("Yes") for ans in ANS: print(*ans)