{$q+,r+,o-}
uses
    math;

const
    max_n = 200;
var
    i, j, k, n, z: longint;
    s: array [2..2 * max_n] of longint;
    p: array [1..max_n * max_n] of longint;
    pd: array [1..max_n * max_n, 1..max_n] of longint;
    pc: array [1..max_n * max_n] of longint;
    f: boolean;
    c: longint;
    p1, p2: array [1..max_n * max_n] of longint;
    f2: boolean;
begin
    while not seekeof do begin
        read(n, z);

        fillchar(s, sizeof(s), 0);
        fillchar(pc, sizeof(pc), 0);
        fillchar(p, sizeof(p), 0);
        for i := 1 to n do begin
            for j := i + 1 to n do begin
                inc(pc[i * j]);
                inc(p[i * j]);
                pd[i * j][pc[i * j]] := i;
                inc(s[i + j]);
            end;
        end;

        k := 0;
        f := true;
        f2 := false;
        while f do begin
            f := false;
            inc(k);

            c := 0;
            if k mod 2 = 1 then begin
                for i := 2 to 2 * n do begin
                    if (s[i] = 1) then begin
                        s[i] := -k;
                        f := true;
                        for j := max(1, i - n) to i div 2 do begin
                            if j = (i - j) then continue;
                            if (p[j * (i - j)] > 0) then begin
                                dec(p[j * (i - j)]);
                                inc(c);
                                p1[c] := j;
                                p2[c] := (i - j);
                            end;
                        end;
                    end;
                end;
            end else begin
                for i := 1 to n * n do begin
                    if (p[i] = 1) then begin
                        p[i] := -k;
                        f := true;
                        for j := 1 to pc[i] do begin
                            if (s[pd[i][j] + i div pd[i][j]] > 0) then begin
                                dec(s[pd[i][j] + i div pd[i][j]]);
                                inc(c);
                                p1[c] := pd[i][j];
                                p2[c] := i div pd[i][j];
                            end;                        
                        end;
                    end;
                end;
            end;
            
            if k = z + 1 then begin
                writeln(c);
                for i := 1 to c do begin
                    writeln(p1[i], ' ', p2[i]);
                end;
                f2 := true;
                f := false;
            end;
        end;
        if not f2 then begin
            writeln(0);
        end;
    end;

    close(input);
    close(output);
end.