favorite We need a little bit of your help to keep things running, click on this banner to learn more

Jumps on strip

Jumps on strip

The horizontal strip 1 x n is divided into cells of size 1 x 1. In the cell with number s there is a checker piece. In the first turn, a piece should move one cell (left or right). Second move should be made through two cells, etc. Each next move should be greater than previous one by 1. So it has been continued while a checker piece has moves not overstepping the bounds of strip.

Your task is to determine maximal and minimal numbers of moves that a piece can move.


The first line contains the number of test cases t (1t20). Each of following t lines consists of two integer numbers n and s (1n1018, 1sn), defining data of corresponding case.


Output file should be contains t lines. The each of lines should be consists two integer number: maximal and minimal numbers of moves of a checker piece for corresponding test case.

Time limit 1 second
Memory limit 122.17 MiB
Input example #1
3 2
6 2
Output example #1
2 2
5 3
Author В.Неспирный
Source Зимние сборы в Харькове 2010 День 1