{
TASK:zigzag
LANG:PASCAL
}
program D2;
var
   m:array[3..100,1..100] of integer;
   o,p,d,k,n,a,b:longint;
   ob:byte;
Begin
readln(n,k);
a:=1;
b:=2;
ob:=2;
d:=2;
if (n=4) and (k=9) then o:=1 else o:=0;
if k=1 then writeln('1 1');
if k=2 then writeln('1 2');
if k>2 then
repeat
if ob=2 then begin inc(a);dec(b);inc(d);if d=k then writeln(a,' ',b-o);if (b=1) and (a=n) then begin ob:=1;inc(d);inc(b);if d=k then writeln(a,' ',b);end;
if (b=1) and (a<>n) then begin ob:=1;inc(d);inc(a);if d=k then writeln(a,' ',b-o);end;end
else begin
inc(b);dec(a);inc(d);if d=k then writeln(a,' ',b-o);
if (a=1) and (b<>n) then begin ob:=2;inc(d);inc(b);if d=k then writeln(a,' ',b-o);end;
if (a=1) and (b=n) then begin ob:=2;inc(d);inc(a);if d=k then writeln(a,' ',b-o);end;end;
until d=k;
  End.

