401935: GYM100589 C Find P'th Number
Description
Alice had a bag where each number from 1 to N was present in it. After a magic trick she either removes all even numbers or all odd numbers from the bag. Given the kind of trick she has performed find the P’th smallest number in the bag after the trick. For example P = 1 denotes the smallest number present.
InputFirst line contains T, the number of test cases. Each test case consists of N, a string S and an integer P in single line.
S will be either "odd" or "even"(quotes for clarity), denoting the kind of trick Alice has performed.
Note: It is guaranteed that P will be less than or equal to remaining items in the bag.
OutputFor each test case print required answer in one line.
Constraints
- 1 ≤ T ≤ 100
- 1 ≤ N ≤ 103
2Output
4 odd 2
5 even 2
4Note
3
Example 1.
After performing the “odd” trick the numbers 1 and 3 get removed from the bag. Numbers 2 and 4 are left in the bag. 2nd smallest number is 4 now.
Example 2.
After performing the “even” trick the numbers 2 and 4 get removed from the bag. Numbers 1, 3 and 5 are left in the bag. 2nd smallest number is 3 now.