import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string; auto rdsp(){return readln.splitter;} void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;} void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);} void writeA(T)(size_t n,T t){foreach(i,v;t.enumerate){write(v);if(i k*(n-k)) { writeln("NO"); return; } writeln("YES"); writeA(n, iota(1, n+1)); foreach (i; 0..k) { writeln(i+1, " ", k+i+1); if (k+i+1 < n) writeln(i+1, " ", k+i+2); } auto c = n-1; foreach (i; 0..k) foreach (j; k..n) { if (i+k == j || i+k+1 == j) continue; writeln(i+1, " ", j+1); ++c; if (c == m) return; } }