Scanf.scanf "%d %d" (fun n m ->
    if n mod 2 = 1 then (
        for i = 1 to m do
            Printf.printf "%d %d\n" i (n - i)
        done
    ) else (
        let m1 = (m + 1) / 2 in
        let m2 = m - m1 in
        for i = 1 to m1 do
            Printf.printf "%d %d\n" i (m1 * 2 + 1 - i)
        done;
        for i = 1 to m2 do
            Printf.printf "%d %d\n" (m1 * 2 + 1 + i) (m1 * 2 + 1 + m2 * 2 + 2 - i)
        done
    )
)