func_code_string: #include <bits/stdc++.h>   using namespace std;   bool G[30][30];   int main() {     int T;     scanf( %d , &T);     while (T--) {       int n, p;       scanf( %d%d , &n, &p);       memset(G, 0, sizeof(G));       for (int i = 0; i < n; ++i)         G[i][(i + 1) % n] = G[(i + 1) % n][i] = G[i][(i + 2) % n] =             G[(i + 2) % n][i] = 1;       for (int step = 3; p; ++step) {         for (int i = 0; p && i < n; ++i) {           G[i][(i + step) % n] = G[(i + step) % n][i] = 1;           --p;         }       }       for (int i = 0; i < n; ++i)         for (int j = i + 1; j < n; ++j)           if (G[i][j]) printf( %d %d n , i + 1, j + 1);     }     return 0;   }   