# Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

# Save Sherlock's Friend

By deshchow.00 · Limits 1s, 512 MB

Sherlock and Dr. Watson are investigating a very rare case in China. Suddenly in the middle of the investigation, Dr. Watson is arrested and sent to jail for interfacing on some internal matters of the Chinese government. Now, Sherlock becomes very disappointed by losing his partner. He secretly goes to jail on the very next day to rescue his friend.

The jail is a $3×n$ grid and his friend is in the cell $(f(x), f(y))$, where, $f(x)$ and $f(y)$ are two functions such that,

For every function $f: N→N$, which maintains the following laws:

But Sherlock looks that it is not enough to find out the cell only in which his friend is kept as a prisoner because every cell is password protected.

So, he must have to know the correct password to unlock the cell. The password can be got by solving a puzzle which looks quite like that in the following for a $3×6$ grid,

Here, the $cell (i, j)$ contains the correct password for this specific cell. Here, $cell(i, j)$ represents the ith row and jth column in the grid where $1\leq i\leq3$ and $1\leq j\leq n$. Though Sherlock is a very intelligent guy, it becomes too tough for him. Now, you have to help Sherlock to find out the cell first from given $x$, $y$, and then giving him the password of the cell, which is required to rescue his friend.

## Input

The input consists of multiple test cases. The first line contains a single integer $t (1\leq t\leq 1000)$ — the number of test cases. Next $t$ lines contain descriptions of test cases.

For each test case the only line contains two integers $x, y(1\leq x, y\leq 93)$.

## Output

Print “WOW! Dr. Watson escaped from the jail”, If there is no valid cell where his friend can be found. Otherwise, print one line with a single integer-the password that is required to rescue his friend from the cell he is in.

## Sample

InputOutput
1
2 2

6


### Statistics

0% Solution Ratio

### Submit

Login to submit

### Related Contests

 Intra MU Junior Programming Contest Autumn 2020 Ended 3w ago Replay of Intra MU Junior Programming Contest Autumn 2020 Ended 2w ago