n,k = map(int,input().split()) if k == 0 or k < n//2: print(-1) exit() ans = [[i,i] for i in range(1,n+1)] sans = [] k = n-k while k: a,b = ans.pop() c,d = ans.pop() sans.append([a,d]) sans.append([a,b]) sans.append([c,d]) k -= 1 while ans: sans.append(ans.pop()) print(len(sans)) for i in sans: print(*i)