{
TASK:zigzag
LANG:PASCAL
}
var n,k:integer;
    ch,i,j,st,z:1..100;
   a:array[1..100,1..100]of 1..10000;
procedure zigzag(n,k:integer);
 begin
   a[1,1]:=1;
   a[n,n]:=n*n;
   st:=2;
   ch:=1;
  if n mod 2=1 then begin
   for j:=2 to n do
    begin
     if st mod 2=0 then
       for i:=1 to st do
       begin
        ch:=ch+1;
        a[i,st-i+1]:=ch;
       end
      else
      for i:=1 to st do
        begin
         ch:=ch+1;
         a[st-i+1,i]:=ch;
        end;
     st:=st+1;
    end;
    st:=n-1;
    ch:=n*n;
   for j:=2 to n do
    begin
     if st mod 2=0 then
      for i:=n downto st do
       begin
        ch:=ch-1;
        a[i,st-i+n]:=ch;
       end
     else
     for i:=n downto st do
       begin
        ch:=ch-1;
        a[st-i+n,i]:=ch;
       end;
     st:=st-1;
     end;
   end
  else
   begin
    for j:=2 to n do
    begin
     if st mod 2=0 then
       for i:=1 to st do
       begin
        ch:=ch+1;
        a[i,st-i+1]:=ch;
       end
      else
      for i:=1 to st do
        begin
         ch:=ch+1;
         a[st-i+1,i]:=ch;
        end;
     st:=st+1;
    end;
    st:=n-1;
    ch:=n*n;
   for j:=2 to n do
    begin
     if st mod 2=0 then
      for i:=n downto st do
       begin
        ch:=ch-1;
        a[st-i+n,i]:=ch;
       end
     else
     for i:=n downto st do
       begin
        ch:=ch-1;
        a[i,st-i+n]:=ch;
       end;
     st:=st-1;
     end;
   end;
  exit;
 end;
begin
readln(n,k);
zigzag(n,k);
for i:=1 to n do
 for j:=1 to n do
  if a[i,j]=k then write(i,' ',j);
end.


