choco-boxes

In a room there are N empty boxes in a row indexed from 1 to N. At a time, 2 people enter the room each having a chocolate bar with him. The 1st person puts the chocolate inside the box which has the least number of chocolates moving from 1 to N. The 2nd person puts the chocolate inside the box which has the least number of chocolates moving from N to 1. Next 2 people enter the room when the earlier two people have left. Find the index of the box and the number of chocolates already kept inside that box for the Mth person.

Note:  In case M is odd, the last person walks into the room alone and puts the chocolate inside the box containing least number of chocolates moving from 1 to N.

Input Format :
The first line contains T, the number of test cases. Each test case consists of one line containing N, the number of boxes, and M, the person to enter the room, separated by space.
Output Format:
The index of the box inside which the Mth person puts the chocolate and number of chocolates already kept inside that box.

Constraints: 
1≤T≤10 
1≤N≤50000 
1≤M≤10^6

SAMPLE INPUT
3
6 4
3 5
5 26

SAMPLE OUTPUT
5 0
1 1
5 5

Source: hackerearth | Difficulty: UNKNOWN_DIFFICULTY


Solutions: