Under construction

Still being built. Things may change

Hedgehog Graph 2

Time limit2.5sMemory limit1024 MB

Summary
Given up to 10 functional graphs shaped like a cycle with trees of depth 1, find each cycle length using at most 900 queries that jump x steps from a chosen vertex.
Level

Hard8 of 10

Topics
Implementation, Math, Number theory
Solved
No attempts yet

Problem

This is an interactive problem.

Isn't a hedgehog cute?

A cute hedgehog!

Kipa also has the "sea urchin graph," but it makes no sense for there to be no graph matching such a cute hedgehog. So Kipa decided to make the hedgehog graph.

A hedgehog graph is an undirected connected graph that satisfies the following two properties. It has no self-loops (an edge connecting a vertex vv to itself) and no multiedges (distinct edges e1e_{1} and e2e_{2} connecting the same two distinct vertices vv and ww).

  • There is exactly one cycle. This cycle is called the body of the hedgehog. The size of the body is the number of vertices on the cycle. A cycle always exists, so the body size is always at least 33.
  • Every vertex not on the cycle has degree 11.

Kipa raised many hedgehog graphs, and now has NN hedgehog graphs, each with V=106V = 10^{6} vertices. Kipa decided to pet each hedgehog graph in the following way.

  1. Orient every edge so that each vertex has exactly one outgoing edge. It can be proven that such an orientation always exists for any hedgehog graph. Kipa has already chosen the orientations arbitrarily, so this step is done.
  2. Repeat the following up to M=900M = 900 times.
    1. Choose a vertex vv and a positive integer xx at most 5×10185 \times 10^{18}.
    2. Starting from vv, follow the arrows xx times to pet the hedgehog graph. Since every vertex has exactly one outgoing edge, the endpoint is uniquely determined, and you can find out which vertex it is.

Kipa wants to know the body size of each hedgehog graph, not just pet them. Kipa finds this too hard to figure out, so the second step is left to you.

You must find the body size of each hedgehog graph from the information you get after running step 2 on it.

Input

The first line contains a positive integer NN at most 1010. The interaction starts after that.

Examples1

  1. Example 1

    Input
    1
    
    3
    
    7
    
    10
    
    1
    
    Expected output
    
    ? 1 2
    
    ? 2 5
    
    ? 10 11
    
    ! 11