#arc142c. [arc142_c]Tree Queries

[arc142_c]Tree Queries

Problem Statement

There is a tree with NN vertices, numbered 1,ldots,N1, \\ldots, N.
For each pair of integers u,v,(1lequ,vleqN)u,v\\, (1 \\leq u,v \\leq N), the distance du,vd_{u,v} between Vertices u,vu, v is defined as the following.

  • The number of edges contained in the shortest path connecting Vertices uu and vv.

You are allowed to ask between 00 and 2N2N questions (inclusive) in the following form.

  • Ask the distance du,vd_{u,v} between Vertices u,vu,v for integers u,vu,v of your choice such that 1lequ,vleqN1\\leq u,v \\leq N and u+v>3u+v>3.

Find the distance d1,2d_{1,2} between Vertices 1,21,2.

Constraints

  • 3leqNleq1003 \\leq N \\leq 100
  • NN is an integer.
  • The tree is determined before the start of the interaction between your program and the judge.

Input and Output

This is an interactive task, in which your program and the judge interact via input and output.

First, your program is given a positive integer NN from Standard Input:

NN

Then, you get to ask questions.
A question should be printed in the following format (with a newline at the end):

? uu vv

If the question is valid, the response du,vd_{u,v} is given from Standard Input:

du,vd_{u,v}

If the question is judged invalid because, for example, it is malformed or you have asked too many questions, you get -1 instead of the response:

-1

At this point, your submission is already judged incorrect. The judge's program then terminates; yours should too, desirably.

When you find the answer d1,2d_{1,2}, print it to Standard Output in the following format (with a newline at the end):

! d1,2d_{1,2}

Notices

  • Flush Standard Output after each output. Otherwise, you might get the TLE