#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   using namespace std;   int n, k, a[1010][1010];   vector<pair<int, int>> ans;   int main() {     int is = 0;     ans.clear();     memset(a, 0, sizeof(a));     cin >> n >> k;     for (int i = 1; i <= n; ++i) {       int cnt = 0;       for (int j = 1; j <= n; ++j) {         if (i == j) continue;         if (cnt == k) break;         if (a[j][i] == 0) {           a[i][j] = 1;           ++cnt;           ans.push_back({i, j});         }       }       if (cnt != k) {         cout <<  -1 ;         return 0;       }     }     if (!is) {       cout << ans.size() <<   n ;       for (auto i : ans) {         cout << i.first <<     << i.second <<   n ;       }     }   }   