#include using namespace std; int main(){ int N, K; cin >> N >> K; if (K < (N + 1) / 2){ cout << -1 << endl; } else { vector a(N), b(N); for (int i = 0; i < N; i++){ a[i] = i; b[i] = i; } int M = N; for (int i = 0; i < N - K; i++){ a.insert(a.begin(), i * 2); b.insert(b.begin(), i * 2 + 1); M++; } cout << M << endl; for (int i = 0; i < M; i++){ cout << a[i] + 1 << ' ' << b[i] + 1 << endl; } } }