#include using namespace std; void ng() { cout << -1 << endl; exit(EXIT_SUCCESS); } using P = pair; int main() { int N, K; cin >> N >> K; if (K == 0) { ng(); } int n = -1; vector

es; if (N % 2 == 0) { n = N / 2; if (K < n) { ng(); } for (int i = 0; i < n; ++i) { int u = 2 * i, v = u + 1; if (K - n + i == 0) { es.emplace_back(u, v); es.emplace_back(u, u); es.emplace_back(v, v); K -= 1; } else { es.emplace_back(u, u); es.emplace_back(v, v); K -= 2; } } } else { n = N / 2; if (K < n + 1) { ng(); } es.emplace_back(2 * n, 2 * n); K -= 1; for (int i = 0; i < n; ++i) { int u = 2 * i, v = u + 1; if (K - n + i == 0) { es.emplace_back(u, v); es.emplace_back(u, u); es.emplace_back(v, v); K -= 1; } else { es.emplace_back(u, u); es.emplace_back(v, v); K -= 2; } } } cout << es.size() << endl; for (auto [u, v] : es) { cout << u + 1 << " " << v + 1 << endl; } }