func_code_string: #include <bits/stdc++.h>   using namespace std;   bool a[30][30];   void fun(int x, int y) { a[x][y] = a[y][x] = true; }   int main() {     ios_base::sync_with_stdio(false);     int t;     cin >> t;     while (t--) {       memset(a, false, sizeof a);       int n, p;       cin >> n >> p;       if (n % 2 == 0) {         for (int i = 1; i <= n; i++) {           fun(i, i + 1);         }         fun(1, n);         int last;         for (int i = 1; i + 2 <= n; i += 2) {           fun(i, i + 2);           last = i + 2;         }         fun(2, last);         for (int i = 2; i + 2 <= n - 2; i += 2) {           if (i + 2 == n - 2) {             fun(i, i + 4);             last = i + 2;           } else             fun(i, i + 2);           last = i + 2;         }         fun(last, last + 2);         fun(1, last);         for (int i = 1; i <= n; i++)           for (int j = 1; j <= n and p > 0; j++) {             if (i != j and a[i][j] == false) {               p--;               fun(i, j);             }           }         for (int i = 1; i <= n; i++)           for (int j = 1; j <= n; j++)             if (i < j and a[i][j]) cout << i <<     << j << endl;       } else {         for (int i = 1; i <= n; i++) {           fun(i, i + 1);         }         fun(1, n);         int last;         for (int i = 1; i + 2 <= n; i += 2) {           fun(i, i + 2);           last = i + 2;         }         fun(2, last);         for (int i = 2; i + 2 <= n; i += 2) {           fun(i, i + 2);           last = i + 2;         }         fun(1, last);         for (int i = 1; i <= n; i++)           for (int j = 1; j <= n and p > 0; j++) {             if (i != j and a[i][j] == false) {               p--;               fun(i, j);             }           }         for (int i = 1; i <= n; i++)           for (int j = 1; j <= n; j++)             if (i < j and a[i][j]) cout << i <<     << j << endl;       }     }   }   