{$A+,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}
{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $00100000}
{$APPTYPE console}

uses SysUtils, Math;

const
  nmax = 2000;

var
  n, k : integer;
  i, j, x : integer;
  p, per : array [1..nmax] of integer;
begin
  n:= StrToInt(ParamStr(1));
  k:= StrToInt(ParamStr(2));
  Randseed:= (n + 123) * (k + 321);
  p[1]:= 0;
  for i:= 2 to n do
  begin
    x:= random(i - 1) + 1;
    if k < 0 then
    begin
      for j:= 1 to -k do x:= max(x, random(i - 1) + 1);
    end else
    begin
      for j:= 1 to k do x:= min(x, random(i - 1) + 1);
    end;
    p[i]:= x;
  end;
  for i:= 1 to n do
  begin
    j:= random(i) + 1;
    per[i]:= per[j];
    per[j]:= i;
  end;
  for i:= 2 to n do
  begin
    writeln(per[p[i]], ' ', per[i]);
  end;
end.