Swapping Game
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld

题目描述

FF has dogs numbered 1,2,3,...,n-1,n. At the beginning, the dogs are arranged by their number in ascending order. They are playing a swapping game, the rules of game are as follows:

1. The dogs will swap in every second.

2. If the current number of seconds is odd, then swap the dog which index is and . For example, if , the sequence of dogs is 1,2,3,4,5 and the current time at the beginning(current time is 1), then the dogs will be 2,1,4,3,5 after 1-st second.

3. If the current number of seconds is even, then swap the dog which index is and . For example, if , the sequence of dogs is 2,1,4,3,5 and the current time is 2, then the dogs will be 2,4,1,5,3 after 2-nd seconds.

FF wants to know, what is the index of the dog numbered after k seconds.

输入描述:

The input consists of multiple test cases. The first line contains an integer  --- the number of test cases. The description of the test cases follows.

The only line of each test case contains three integer .

输出描述:

Print t lines for test cases, and every line contains one integer means the index of the dog after swapping.
示例1

输入

复制
3
5 1 3
5 2 3
6 1 4

输出

复制
4
5
3

说明

In first case, there are 5 dogs at the beginning, and the sequence of dogs is 1,2,3,4,5. After 1 second,the sequence is 2,1,4,3,5, now the dog numbered 3 is in index 4.