let () = Scanf.scanf "%d %d" @@ fun n k ->
  if (n - 1) * (n - 2) / 2 < k then
    print_endline "-1"
  else begin
    Printf.printf "%d\n" (n * (n - 1) / 2 - k);
    for v = 1 to n - 1 do
      Printf.printf "%d %d\n" v n
    done;
    let es =
      Array.of_list @@
      List.concat @@ Array.to_list @@ Array.init (n - 1) @@ fun u ->
        List.concat @@ Array.to_list @@ Array.init (n - 1) @@ fun v ->
          if v <= u then []
          else [(u + 1, v + 1)] in
    for i = 0 to (n - 1) * (n - 2) / 2 - k - 1 do
      let u, v = es.(i) in
      Printf.printf "%d %d\n" u v
    done
  end