CF1438F Olha and Igor

Description

This is an interactive problem. Igor wants to find the key to Olha's heart. The problem is, that it's at the root of a binary tree. There is a perfect binary tree of height $ h $ consisting of $ n = 2^{h} - 1 $ nodes. The nodes have been assigned distinct labels from $ 1 $ to $ n $ . However, Igor only knows $ h $ and does not know which label corresponds to which node. To find key to Olha's heart he needs to find the label assigned to the root by making queries of the following type at most $ n+420 $ times: - Select three distinct labels $ u $ , $ v $ and $ w $ ( $ 1 \leq u,v,w \leq n $ ). - In response, Olha (the grader) will tell him the label of the lowest common ancestor of nodes labelled $ u $ and $ v $ , if the tree was rooted at the node labelled $ w $ instead. Help Igor to find the root! Note: the grader is not adaptive: the labels are fixed before any queries are made.

Input Format

N/A

Output Format

N/A

Explanation/Hint

The labels corresponding to the tree in the example are \[ $ 4 $ , $ 7 $ , $ 2 $ , $ 6 $ , $ 1 $ , $ 5 $ , $ 3 $ \], meaning the root is labelled $ 4 $ , and for $ 1 < i \le n $ , the parent of $ p_i $ is $ p_{ \lfloor{\frac{i}{2}}\rfloor } $ .