#P10765. 「CROI · R2」在相思树下 I
「CROI · R2」在相思树下 I
Description
This problem uses multiple test cases.
Xinxin has a sequence from to and wants to perform the following two operations:
Operation 1: Delete all elements at odd positions.
Operation 2: Delete all elements at even positions.
After performing operations, exactly one number remains. Given the sequence of operations, determine the final remaining number.
Input Format
- The first line contains a positive integer , the number of test cases.
- For each test case:
- The first line contains two integers and .
- The second line contains integers representing the operations (1 for Operation 1, 2 for Operation 2).
Output Format
Output lines, each containing the answer for the corresponding test case.
4
5 2
1 1
8 3
2 2 2
8 3
1 1 1
8 3
1 2 1
4
1
8
6
Hint
Explanation
Sample Explanation:
For the first test case, the sequence evolves as:
.
Constraints
- For of the data: .
- For of the data:
- ,
- .
- It is guaranteed that exactly one number remains after operations for all test cases.
京公网安备 11011102002149号