#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[1005];
int b[1005];
int main() {
  cin >> n;
  int a, b;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    int c = 0;
    int k = 1;
    int f = 0;
    while (1) {
      c++;
      for (int t = c + 1; t <= a; t++) {
        cout << c << " " << t << endl;
        if (k == 2 * a + b) {
          f = 1;
          break;
        }
        k++;
      }
      if (f == 1) break;
    }
  }
}
