{"trustable":false,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027$$$$$$\u0027, right: \u0027$$$$$$\u0027, display: true},\n {left: \u0027$$$\u0027, right: \u0027$$$\u0027, display: false},\n {left: \u0027$$\u0027, right: \u0027$$\u0027, display: true},\n {left: \u0027$\u0027, right: \u0027$\u0027, display: false}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"MD","content":"This is an interactive problem.\n\nGiven a tree with $n$ nodes, where node $1$ is the root.\n\nThere is a hidden node $x$, and your goal is to find it. To find this node, you can make two types of queries:\n\n1.d $u$, the system will answer with the distance between node $u$ and node $x$.\n2.s $u$, the system will answer with the second node on the path from node $u$ to node $x$. Note that if $u$ is not an ancestor of $x$, you will receive the response \"Wrong answer\".\n\nOnce you have obtained the answer, output \"! $x$\". Please find the correct answer within $36$ queries."}},{"title":"Input","value":{"format":"MD","content":"\u003cp\u003eThe first line contains the integer $$$n$$$ ($$$2 \\le n \\le 2 \\cdot 10^5$$$)\u0026nbsp;— the number of nodes in the tree.\u003c/p\u003e\n\u003cp\u003eEach of the next $$$n-1$$$ lines contains two space-separated integers $$$u$$$ and $$$v$$$ ($$$1 \\le u,v \\le n$$$) that mean there\u0027s an edge between nodes $$$u$$$ and $$$v$$$. It\u0027s guaranteed that the given graph is a tree.\u003c/p\u003e"}},{"title":"Output","value":{"format":"MD","content":"\u003cp\u003eTo print the answer, print \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e! x\u003c/span\u003e\" (without quotes).\u003c/p\u003e"}},{"title":"Interaction","value":{"format":"MD","content":"\u003cp\u003eTo ask a question, print it in one of the formats above:\u003c/p\u003e\n\u003cul\u003e\n \u003cli\u003e\u003cspan class\u003d\"tex-font-style-tt\"\u003ed\u003c/span\u003e $$$u$$$ ($$$1 \\le u \\le n$$$), or\u003c/li\u003e\n \u003cli\u003e\u003cspan class\u003d\"tex-font-style-tt\"\u003es\u003c/span\u003e $$$u$$$ ($$$1 \\le u \\le n$$$).\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eAfter each question, you should read the answer: either the distance or the second vertex on the path, as mentioned in the legend.\u003c/p\u003e\n\u003cp\u003eIf we answer with $$$-1$$$ instead of a valid answer, that means you exceeded the number of queries, made an invalid query, or violated the condition in the second type of queries. Exit immediately after receiving $$$-1$$$ and you will see \u003cspan class\u003d\"tex-font-style-tt\"\u003eWrong answer\u003c/span\u003e verdict. Otherwise, you can get an arbitrary verdict because your solution will continue to read from a closed stream.\u003c/p\u003e\n\u003cp\u003eAfter printing a query, do not forget to output end of line and flush the output. Otherwise, you will get \u003cspan class\u003d\"tex-font-style-tt\"\u003eIdleness limit exceeded\u003c/span\u003e. To do this, use:\u003c/p\u003e\n\u003cul\u003e\n \u003cli\u003e\u003cspan class\u003d\"tex-font-style-tt\"\u003efflush(stdout)\u003c/span\u003e or \u003cspan class\u003d\"tex-font-style-tt\"\u003ecout.flush()\u003c/span\u003e in C++;\u003c/li\u003e\n \u003cli\u003e\u003cspan class\u003d\"tex-font-style-tt\"\u003eSystem.out.flush()\u003c/span\u003e in Java;\u003c/li\u003e\n \u003cli\u003e\u003cspan class\u003d\"tex-font-style-tt\"\u003eflush(output)\u003c/span\u003e in Pascal;\u003c/li\u003e\n \u003cli\u003e\u003cspan class\u003d\"tex-font-style-tt\"\u003estdout.flush()\u003c/span\u003e in Python;\u003c/li\u003e\n \u003cli\u003eSee the documentation for other languages.\u003c/li\u003e\n\u003c/ul\u003e\n"}},{"title":"Sample 1","value":{"format":"MD","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e5\n1 2\n1 3\n3 4\n3 5\n3\n5\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003ed 2\ns 3\n! 5\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"MD","content":"\u003cp\u003eIn the first example, the hidden node is node $$$5$$$.\u003c/p\u003e\n\u003ccenter\u003e\n \u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/6bd16bfec70f2d58c5dbbda5929b456c?v\u003d1693156757\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e\n\u003c/center\u003e\n\u003cp\u003eWe first ask about the distance between node $$$x$$$ and node $$$2$$$. The answer is $$$3$$$, so node $$$x$$$ is either $$$4$$$ or $$$5$$$. We then ask about the second node in the path from node $$$3$$$ to node $$$x$$$. Note here that node $$$3$$$ is an ancestor of node $$$5$$$. We receive node $$$5$$$ as the answer."}}]}