While training in Holodeck 3, Mr. Worf fires a phaser from one corner at an angle of 45 degrees to both walls, and parallel to the floor. Unfortunately, a fluctuation in one of the power conduit modulators makes all the walls into perfect mirrors, reflecting all phaser blasts in zero time and with no loss in speed. (In particular, a the phaser blast doubles back on itself if it hits a corner.)

The holodeck is a perfect rectangle
*n* HU wide by *k* HU long. It takes
1 nanosecond to cross HU of space. The question: what is
the length of time between
Worf firing the phaser and the time that he gets stunned?
(The
holodeck safeties are also disengaged by the accident, so that he really
does get stunned.)
For the sake of simplicity, Worf is shrunk to take up zero width and breadth,
and the tip of his phaser is positioned exactly in the corner. Also, on
its return trip the
phaser blast passes through the phaser and stuns Worf.

**Input:**
The input to your program is a positive integer *d*, followed by *d*
data sets.
Each data set consists of positive integers *n* and *k*, respectively.

**Output:**
The output for each data set should be the number of nanoseconds before
Mr. Worf gets blasted. The answer for each data set will always be
less than 2000000.

**Sample input:** (*Editor's note: many people noticed that there
are really only two data sets present, and so the "3" here should really
be "2". Sorry!*)

3 1 1 6 12

**Corresponding sample output:**

2 24

**The game of the name:**
My favourite Worf quote is ``It is a good day to die and the
day is not yet over''.

Thu Jan 9 19:12:26 EST 1997