#include <bits/stdc++.h>   using namespace std;   int arr[1001][1001];   int main() {     int n, m, f1 = 0;     cin >> n >> m;     int cnt = m;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (i != j && arr[i][j] == 0) {           arr[i][j] = 1;           arr[j][i] = -1;           cnt--;         }         if (cnt == 0) break;       }       if (cnt > 0) {         f1 = 1;         break;       }       cnt = m;     }     if (f1 == 1)       cout <<  -1  << endl;     else {       cout << n * m << endl;       for (int i = 0; i < n; i++) {         for (int j = 0; j < n; j++)           if (arr[i][j] == 1) cout << i + 1 <<     << j + 1 << endl;       }     }     return 0;   }   