import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); sc.close(); if (k == 0) { System.out.println(-1); return; } List list = new ArrayList<>(); for (int i = 1; i <= k; i++) { list.add(i + " " + i); } for (int i = k + 1; i <= n; i++) { list.add("1 " + i); list.add(i + " " + i); } PrintWriter pw = new PrintWriter(System.out); pw.println(list.size()); for (String s : list) { pw.println(s); } pw.flush(); } }