#abc370b. B - Binary Alchemy
B - Binary Alchemy
Score : points
问题陈述
有 种元素,编号为 。
元素可以相互结合。当元素 和 结合时,如果 ,则它们转化为元素 ;如果 ,则转化为元素 。
从元素 开始,依次与元素 结合。找出最终获得的元素。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
There are types of elements numbered .
Elements can be combined with each other. When elements and are combined, they transform into element if , and into element if .
Starting with element , combine it with elements in this order. Find the final element obtained.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the number representing the final element obtained.
Sample Input 1
4
3
2 4
3 1 2
2 1 2 4
Sample Output 1
2
-
Combining element with element results in element .
-
Combining element with element results in element .
-
Combining element with element results in element .
-
Combining element with element results in element .
Therefore, the value to be printed is .
Sample Input 2
5
5
5 5
5 5 5
5 5 5 5
5 5 5 5 5
Sample Output 2
5
Sample Input 3
6
2
1 5
1 6 3
2 6 1 4
2 1 1 1 6
5 6 1 2 2 5
Sample Output 3
5