{"raw_statement":[{"iden":"statement","content":"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.\n\nFirst line contains T, the number of test cases. Each test case consists of N, a string S and an integer P in single line.\n\nS will be either \"odd\" or \"even\"(quotes for clarity), denoting the kind of trick Alice has performed.\n\nNote: It is guaranteed that P will be less than or equal to remaining items in the bag.\n\nFor each test case print required answer in one line.\n\n*Constraints* \n\nExample 1.\n\nAfter 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.\n\nExample 2.\n\nAfter 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.\n\n"},{"iden":"input","content":"First 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."},{"iden":"output","content":"For each test case print required answer in one line.*Constraints*   1 ≤ T ≤ 100  1 ≤ N ≤ 103 "},{"iden":"examples","content":"Input24 odd 25 even 2Output43"},{"iden":"note","content":"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."}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ T \\in \\mathbb{Z} $ be the number of test cases.  \nFor each test case $ k \\in \\{1, \\dots, T\\} $:  \n- Let $ N_k \\in \\mathbb{Z}^+ $ denote the upper bound of the initial set $ \\{1, 2, \\dots, N_k\\} $.  \n- Let $ S_k \\in \\{\\text{\"odd\"}, \\text{\"even\"}\\} $ denote the type of removal trick.  \n- Let $ P_k \\in \\mathbb{Z}^+ $ denote the position of the desired element in the remaining set.  \n\n**Constraints**  \n1. $ 1 \\le T \\le \\text{some upper bound (not specified)} $  \n2. $ 1 \\le N_k \\le \\text{some upper bound (not specified)} $  \n3. $ 1 \\le P_k \\le \\text{number of remaining elements after removal} $  \n\n**Objective**  \nFor each test case $ k $, define the remaining set $ R_k \\subseteq \\{1, 2, \\dots, N_k\\} $ as:  \n$$\nR_k = \n\\begin{cases}\n\\{ x \\in \\{1, \\dots, N_k\\} \\mid x \\text{ is odd} \\} & \\text{if } S_k = \\text{\"even\"} \\\\\n\\{ x \\in \\{1, \\dots, N_k\\} \\mid x \\text{ is even} \\} & \\text{if } S_k = \\text{\"odd\"}\n\\end{cases}\n$$  \nLet $ r_{k,1} < r_{k,2} < \\dots < r_{k,|R_k|} $ be the sorted elements of $ R_k $.  \nCompute and output $ r_{k,P_k} $.","simple_statement":"Alice had numbers from 1 to N in a bag. She removes all even numbers or all odd numbers. Given the type of removal (\"odd\" or \"even\"), find the P-th smallest number left in the bag.","has_page_source":false}