#include <bits/stdc++.h>
const long long mod = (long long)1e9 + 7;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    long long n = (2 * a) + b;
    for (long long i = 1; i <= 1e5; i++) {
      for (long long j = i + 1; j <= a; j++) {
        cout << i << " " << j << "\n";
        n--;
        if (n == 0) break;
      }
      if (n == 0) break;
    }
  }
  return 0;
}
