Let's call an undirected graph of n vertices p-interesting, if the following conditions fulfill: 

  * the graph contains exactly 2n + p edges; 
  * the graph doesn't contain self-loops and multiple edges; 
  * for any integer k (1 ≤ k ≤ n), any subgraph consisting of k vertices contains at most 2k + p edges. 



A subgraph of a graph is some set of the graph vertices and some set of the graph edges. At that, the set of edges must meet the condition: both ends of each edge from the set must belong to the chosen set of vertices. 

Your task is to find a p-interesting graph consisting of n vertices.

Input

The first line contains a single integer t (1 ≤ t ≤ 5) — the number of tests in the input. Next t lines each contains two space-separated integers: n, p (5 ≤ n ≤ 24; p ≥ 0; <image>) — the number of vertices in the graph and the interest value for the appropriate test. 

It is guaranteed that the required graph exists.

Output

For each of the t tests print 2n + p lines containing the description of the edges of a p-interesting graph: the i-th line must contain two space-separated integers ai, bi (1 ≤ ai, bi ≤ n; ai ≠ bi) — two vertices, connected by an edge in the resulting graph. Consider the graph vertices numbered with integers from 1 to n. 

Print the answers to the tests in the order the tests occur in the input. If there are multiple solutions, you can print any of them.

Examples

Input

1
6 0


Output

1 2
1 3
1 4
1 5
1 6
2 3
2 4
2 5
2 6
3 4
3 5
3 6
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:66777216")
using namespace std;
int a, b, c, d, n, m, k, p, kolt;
bool sm[26][26];
vector<pair<int, int> > solve(int n, int p) {
  set<pair<int, int> > deg;
  for (int _n((n)-1), i(0); i <= _n; i++) deg.insert(make_pair(0, i));
  vector<pair<int, int> > res;
  memset((sm), 0, sizeof(sm));
  for (int _n((2 * n + p) - 1), i(0); i <= _n; i++) {
    pair<int, int> t1 = make_pair(-1, -1);
    pair<int, int> t2 = make_pair(-1, -1);
    for (int _n((n)-1), md(0); md <= _n; md++) {
      for (set<pair<int, int> >::iterator it = deg.begin(); it != deg.end();
           ++it) {
        if (it->first > md) break;
        for (set<pair<int, int> >::iterator it2 = deg.begin(); it2 != it;
             ++it2) {
          if (it2->first > md) break;
          if (sm[it->second][it2->second]) continue;
          t1 = *it;
          t2 = *it2;
          break;
        }
        if (t1.first != -1) break;
      }
      if (t1.first != -1) break;
    }
    deg.erase(deg.find(t1));
    deg.erase(deg.find(t2));
    ++t1.first;
    ++t2.first;
    res.push_back(make_pair(t1.second, t2.second));
    sm[t1.second][t2.second] = sm[t2.second][t1.second] = 1;
    deg.insert(t1);
    deg.insert(t2);
  }
  return res;
}
int main() {
  scanf("%d", &kolt);
  for (int _n((kolt)), hod(1); hod <= _n; hod++) {
    memset((sm), 0, sizeof(sm));
    scanf("%d%d", &n, &p);
    vector<pair<int, int> > res = solve(n, p);
    for (int _n(((int)((res).size())) - 1), i(0); i <= _n; i++) {
      printf("%d %d\n", res[i].first + 1, res[i].second + 1);
    }
  }
}
