#include <bits/stdc++.h>
using namespace std;
int main() {
  int x;
  cin >> x;
  while (x--) {
    int a, b;
    bool test = false;
    cin >> a >> b;
    int count = a * 2 + b;
    for (int i = 1; i <= a; i++) {
      for (int j = i + 1; j <= a; j++) {
        count--;
        cout << i << " " << j << endl;
        if (count == 0) {
          test = true;
          break;
        }
      }
      if (test == true) break;
    }
  }
}
