Lord Omkar would like to have a tree with n nodes (3 ≤ n ≤ 10^5) and has asked his disciples to construct the tree. However, Lord Omkar has created m (1 ≤ m < n) restrictions to ensure that the tree will be as heavenly as possible. 

A tree with n nodes is an connected undirected graph with n nodes and n-1 edges. Note that for any two nodes, there is exactly one simple path between them, where a simple path is a path between two nodes that does not contain any node more than once.

Here is an example of a tree: 

<image>

A restriction consists of 3 pairwise distinct integers, a, b, and c (1 ≤ a,b,c ≤ n). It signifies that node b cannot lie on the simple path between node a and node c. 

Can you help Lord Omkar and become his most trusted disciple? You will need to find heavenly trees for multiple sets of restrictions. It can be shown that a heavenly tree will always exist for any set of restrictions under the given constraints.

Input

Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4). Description of the test cases follows.

The first line of each test case contains two integers, n and m (3 ≤ n ≤ 10^5, 1 ≤ m < n), representing the size of the tree and the number of restrictions.

The i-th of the next m lines contains three integers a_i, b_i, c_i (1 ≤ a_i, b_i, c_i ≤ n, a, b, c are distinct), signifying that node b_i cannot lie on the simple path between nodes a_i and c_i. 

It is guaranteed that the sum of n across all test cases will not exceed 10^5.

Output

For each test case, output n-1 lines representing the n-1 edges in the tree. On each line, output two integers u and v (1 ≤ u, v ≤ n, u ≠ v) signifying that there is an edge between nodes u and v. Given edges have to form a tree that satisfies Omkar's restrictions.

Example

Input


2
7 4
1 2 3
3 4 5
5 6 7
6 5 4
5 3
1 2 3
2 3 4
3 4 5


Output


1 2
1 3
3 5
3 4
2 7
7 6
5 1
1 3
3 2
2 4

Note

The output of the first sample case corresponds to the following tree: 

<image> For the first restriction, the simple path between 1 and 3 is 1, 3, which doesn't contain 2. The simple path between 3 and 5 is 3, 5, which doesn't contain 4. The simple path between 5 and 7 is 5, 3, 1, 2, 7, which doesn't contain 6. The simple path between 6 and 4 is 6, 7, 2, 1, 3, 4, which doesn't contain 5. Thus, this tree meets all of the restrictions.

The output of the second sample case corresponds to the following tree: 

<image>
#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key
#define int long long
#define pii pair<int,int>
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b)
{    if(a.first==b.first)return (a.second > b.second);
    else  return (a.first < b.first);}
int min(int x,int y){if(x<y)return x;else return y;}
int max(int x,int y){if(x>y)return x;else return y;}
unsigned long long power(unsigned long long x,int y, int p);
// vector<vector<int> > adj(200001); // adjacency list
// vector<bool> vis(200001);
// //  int a[100001];
// //  int exist;
// //  int dal;
// //  vector<int> val;
//  void dfs(int node)
// {  
//     vis[node]=true;
  
    
    
//     for(auto child: adj[node])
//     { 
//         if (!vis[child])
//         {      dfs(child);
            
            
//         }
//     }

    
    
   
// }

// int rnk[400005];
// int par[400005];
 
// void make_set(int n)
// {
// for(int i=1; i<=n; i++)
// {
// par[i] = i;
// rnk[i] = 1;
// }
// }
// int find_set(int x)
// {
// if( par[x] == x)
// {
// return x;
// }
// par[x]=find_set(par[x]);
// return par[x];
// }
 
// void union_set(int a, int b)
// {
// int p1 = find_set(a);
// int p2 = find_set(b);
// if ( p1 == p2)
// return;
// if (rnk[p1] > rnk[p2])
// {
// par[p2]=p1;
// rnk[p1] = rnk[p1] + rnk[p2];
// }
// else
// {
// par[p1] = p2;
// rnk[p2] = rnk[p1] + rnk[p2];
// }
// }
#define MAXN   100001
 
// stores smallest prime factor for every number
int spf[MAXN];
 
// Calculating SPF (Smallest Prime Factor) for every
// number till MAXN.
// Time Complexity : O(nloglogn)
void sieve()
{
    spf[1] = 1;
    for (int i=2; i<MAXN; i++)
 
        // marking smallest prime factor for every
        // number to be itself.
        spf[i] = i;
 
    // separately marking spf for every even
    // number as 2
    for (int i=4; i<MAXN; i+=2)
        spf[i] = 2;
 
    for (int i=3; i*i<MAXN; i++)
    {
        // checking if i is prime
        if (spf[i] == i)
        {
            // marking SPF for all numbers divisible by i
            for (int j=i*i; j<MAXN; j+=i)
 
                // marking spf[j] if it is not
                // previously marked
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}
int mod=1e9+7;
int32_t main()
{    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     sieve();
      int t;
      cin>>t;
      while(t--)
      {
       

       int n,m;
       cin>>n>>m;
       int a[m],b[m],c[m];
       map<int,int> mp;
       for(int i=0;i<m;i++)
       {
           cin>>a[i]>>b[i]>>c[i];
           mp[b[i]]++;
       }
       int pos=0;
       for(int i=1;i<=n;i++)
       {
           if(mp[i]==0)
           {
               pos=i;
               break;
           }

       }
        for(int i=1;i<n;i++)
        { if(i!=pos)
          {
              cout<<pos<<" "<<i<<endl;
          }

        }
         
      }
   
       


 
    return 0;
}
//     val.clear();
    // 	val.resize(n+1);
    //   for(int i=1;i<=n;i++){
	// 		while(!adj[i].empty())adj[i].pop_back();
	// 	}
    //    for(int i=0;i<=n;i++){
    //          vis[i]=false;
    //      }
    //   for(int i=0;i<n-1;i++)
    //   {   int al,bl;
    //        cin>>al>>bl;
    //       adj[al].pb(bl);
    //       adj[bl].pb(al);
    //   }
unsigned long long power(unsigned long long x,
                                   int y, int p)
{
    unsigned long long res = 1; // Initialize result
 
    x = x % p; // Update x if it is more than or
    // equal to p
 
  if (y == 0) return 1;
    if (x == 0) return 0; 
    while (y > 0)
    {
     
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res * x) % p;
 
        // y must be even now
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}