($N,$M)=glob<>; exit!print'NO'if$M>($a=$N>>1)*($b=$N-$a)|$M<$N-1; print"YES\n@{[1..$N]}\n"; print$_%$a+1,$",$a+1+($_%$a+$_/$a)%$b,$/for 0..$M-1