let rec for_fold a b v f = if a > b then v else for_fold (a+1) b (f a v) f
let rec drop n = function [] -> [] | x::xs -> if n = 0 then x::xs else drop (n-1) xs
let () =
  Scanf.scanf "%d %d" @@ fun n k ->
  if n*(n-1)/2 - k < n-1 then print_endline "-1" else begin
    Printf.printf "%d\n" (n*(n-1)/2 - k);
    for_fold 1 n [] (fun i g -> (for_fold (i+1) n g (fun j g -> (j, i) :: g)))
    |> drop k |> List.iter (fun (a, b) -> Printf.printf "%d %d\n" a b)
  end