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.io.*;
import java.util.*;

public class TaskC {


    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);


        int t = sc.nextInt();

        while (t--> 0 )
        {
            int n = sc.nextInt();
            int p = sc.nextInt();

            boolean[][] adjMat = new boolean[n + 1][n + 1];

            int total = 2*n + p;
            for (int i = 1 ; i <= n ;i++)
                adjMat[i][i] = true;

            for (int i = 1 ; i <= n - 1 && total > 0;i ++)
            {
                adjMat[i][i+1] = true;
                adjMat[i+1][i] = true;
                total--;
            }
            adjMat[1][n] = true;
            adjMat[n][1] = true;
            total--;

            for (int i = 1 ; i <= n && total > 0; i++)
                for (int j = 1 ; j <= n && total > 0; j++)
                {
                    if(!adjMat[i][j])
                    {
                        total--;
                        adjMat[i][j] = true;
                        adjMat[j][i] = true;
                    }
                }
            for (int i = 1 ; i <= n ; i++)
                for (int j = 1 ; j <= n ; j++)
                {
                    if(adjMat[i][j] && i!=j)
                    {
                        pw.println(i + " " +j);
                        adjMat[i][j] = false;
                        adjMat[j][i] = false;
                    }

                }
        }


        pw.close();

    }



    private static long gcd(long a, long b) {
        if( b == 0)
            return a;
        return gcd(b  , a%b);
    }

    static long lcm(int a, int b)
    {
        return (a*b)/gcd(a, b);
    }


    private  static int dis(int xa , int ya , int xb , int yb)
    {
        return (xa-xb)*(xa - xb) + (ya- yb)*(ya-yb);
    }


    static class Pair1 extends Pair{
        int idx;
        public Pair1(int x, int y , int idx) {
            super(x, y);
            this.idx = idx;
        }

        public int compareTo(Pair o) {

            if(y == o.y)
                return x - o.x;
            return o.y  - y;
        }

        public String toString()
        {
            return x + " " + y +" "+idx;
        }
    }
    static class Pair implements Comparable<Pair> {
        int x,y;


        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public int compareTo(Pair o) {
            if (x == o.x)
                return y - o.y;
            return x - o.x;
        }
        public double dis(Pair a){
         //   return  0;
            return (a.x - x)*(a.x - x) + (a.y-y)*(a.y-y);
        }
        public String toString() {
            return  x+" "+ y;
        }
        public boolean overlap(Pair a)
        {
        if((this.x >= a.x && this.x <= a.y) || (a.x >= this.x && a.x <= this.y)) return true;
            return false;

        }
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public boolean check() {
            if (!st.hasMoreTokens())
                return false;
            return true;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public String nextLine() {
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }

        public double nextDouble() {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() {
            try {
                return br.ready();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
}