total_input=int(input())
for _ in range(total_input):
n,e=map(int,input().split())
g={n:[]}
for i in range(1,n):
g[i]=[i+1]
print(i,i+1)
e-=1
end=3
while e>0:
for i in range(1,end):
if g[i][-1]<end:
g[i].append(end)
print(i,end)
e-=1
if e==0:break
end+=1
582B - Once Again | 551C - GukiZ hates Boxes |
1406D - Three Sequences | 148E - Porcelain |
1468F - Full Turn | 865D - Buy Low Sell High |
496B - Secret Combination | 144D - Missile Silos |
696B - Puzzles | 1750B - Maximum Substring |
1237B - Balanced Tunnel | 1750D - Count GCD |
1750C - Complementary XOR | 1552E - Colors and Intervals |
1750A - Indirect Sort | 59B - Fortune Telling |
888B - Buggy Robot | 637A - Voting for Photos |
557B - Pasha and Tea | 106B - Choosing Laptop |
116B - Little Pigs and Wolves | 644B - Processing Queries |
1427B - Chess Cheater | 1573C - Book |
831A - Unimodal Array | 220B - Little Elephant and Array |
1426E - Rock Paper Scissors | 569A - Music |
1662M - Bottle Arrangements | 1662H - Boundary |