#ADAAPHID. Ada and Aphids

Ada and Aphids

Ada the Ladybug breeds aphids. Whenever a new aphid is born, she assigns him an ID. She did that for long time but as she can't remember tha ID's she sometime made duplicates. She wanted to avoid such situation so she extended the ID to pair. She has also chosen a random number, which she assigned to aphid and then she made second integer of ID as sum of values of all aphids with ID lesser or equal to current ID (including current ID).

She wants to know the ID of each aphid. Please, read the input section carefully.

Input

The first line contains 1 ≤ Q ≤ 3*105 , number of aphids added.

Let L be the second integer of last aphid's ID (beggining with 0).

The next Q lines contains two numbers A, V, 0 ≤ A, V < 260, where A ⊕ L is the first integer of aphid's ID and V ⊕ L is the random number ( stands for XOR).

1 ≤ A ⊕ L < 260

1 ≤ V ⊕ L < 1000

Output

For each query print both number's of aphid's ID.

Example Input

7
1 1
3 3
4 0
3 2
5 6
13 13
19 19

Example Output

1 1
2 3
7 6
5 7
2 4
9 20
7 18

Input after XOR

7
1 1
2 2
7 3
5 4
2 1
9 9
7 7