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
    import java.util.*;
    import java.io.*;
    
    public class A {
        public static long time = 0;
    
        public static void main(String[] args) throws Exception {
            time = System.currentTimeMillis();
    
            IN = System.in;
            OUT = System.out;
            in = new BufferedReader(new InputStreamReader(IN));
            out = new PrintWriter(OUT, FLUSH);
            solveOne();
            out.flush();
        }
    
        public static void solveOne() throws Exception {
            int n1 = ni();
            for (int i = 0 ; i < n1; i++){
                solveTwo();
            }
    
        }
    
        public static void solveTwo() throws Exception {
            int vNo = ni();
            int extraNo = ni();
            int totalNo = vNo * 2 + extraNo;
            for (int i = 0; i < totalNo; i++){
                int mult = i / vNo;
                int rmd = i % vNo;
                int inc = mult + 1;
                int curStart = rmd;
                int curEnd = rmd + inc;
                curStart %= vNo;
                curEnd %= vNo;
                pn(curStart + 1, curEnd + 1);
            }
        }
    
        public static void solveThree() throws Exception {
    
        }
    
        public static BufferedReader in;
        public static StringTokenizer st;
        public static InputStream IN;
        public static OutputStream OUT;
    
        public static String nx() throws Exception {
            for (; st == null || !st.hasMoreTokens();) {
                String k1 = in.readLine();
                if (k1 == null) return null;
                st = new StringTokenizer(k1);
            }
            return st.nextToken();
        }
    
        public static int ni() throws Exception {
            return Integer.parseInt(nx());
        }
    
        public static long nl() throws Exception {
            return Long.parseLong(nx());
        }
    
        public static double nd() throws Exception {
            return Double.parseDouble(nx());
        }
    
        public static void px(Object... l1) {
            System.out.println(Arrays.deepToString(l1));
        }
    
        public static boolean FLUSH = false;
        public static PrintWriter out;
    
        public static void p(Object... l1) {
            for (int i = 0; i < l1.length; i++) {
                if (i != 0) out.print(' ');
                out.print(l1[i].toString());
            }
        }
    
        public static void pn(Object... l1) {
            for (int i = 0; i < l1.length; i++) {
                if (i != 0) out.print(' ');
                out.print(l1[i].toString());
            }
            out.println();
        }
    
        public static void pn(Collection l1) {
            boolean first = true;
            for (Object e : l1) {
                if (first) first = false;
                else out.print(' ');
                out.print(e.toString());
            }
            out.println();
        }
    
    }
