**Chocolate Bunny SOLUTION**

**Chocolate Bunny SOLUTION**

This is a natural issue. We got away from you a phase p of length n, involving the parts from 1 to n. You have to get it. To do that, you can give us 2 unmistakable records I and j, and we will reply with pimodpj (rest of division pi by pj).

We have enough resilience to answer everything thought about 2⋅n requests, so you should fit in this constraint. OK have the option to do it?

As an update, a difference in length n is a group containing n undeniable numbers from 1 to n in self-confident solicitation. For example, [2,3,1,5,4] is a phase, anyway [1,2,2] isn’t a change (2 shows up twice in the display) and [1,3,4] is in like manner not a change (n=3 yet there is 4 in the group).

Information

The principle line of the information contains a singular entire number n (1≤n≤104) — length of the change.

Affiliation

The affiliation starts with getting n.

By then you are allowed to make everything thought about 2⋅n inquiries in the going with way:

“? x y” (1≤x,y≤n,x≠y).

After each one, you ought to scrutinize a number k, that approaches pxmodpy.

Right when you have estimated the stage, print a single line “! ” (without refers to), followed by show p and quit.

In the wake of printing an inquiry make sure to yield end of line and flush the yield. Else, you will get Idleness limit outperformed. To do this, usage:

fflush(stdout) or cout.flush() in C++;

System.out.flush() in Java;

flush(output) in Pascal;

stdout.flush() in Python;

see documentation for various lingos.

Leave following getting “- 1” and you will see Wrong answer choice. Else you can get an optional choice because your answer will continue scrutinizing from a shut stream.

Hack structure

In the essential line yield n (1≤n≤104). In the resulting line print the phase of n numbers p1,p2,… ,pn.

Model

inputCopy

3

1

2

1

0

outputCopy

? 1 2

? 3 2

? 1 3

? 2 1

! 1 3 2

#include

#include

#include

#define MOD 1000000007

#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();

#define FILE_READ_IN freopen("input.txt","r",stdin);

#define FILE_READ_OUT freopen("output.txt","w",stdout);

#define all(a) a.begin(),a.end()

#define ld long double

#define ll long long int

using namespace std;

int main()

{

ll t;

cin>>t;

while(t–)

{

ll n;

cin>>n;

ll a[n];

map mp;

for(ll i=0;i>a[i];

mp[a[i]]++;

}

auto comp = [](pair p1,pairp2) {return p1.second < p2.second;};

priority_queue , vector> , decltype(comp)> pq(comp);

for(auto c:mp)

{

pair p = {c.first,c.second};

pq.push(p);

}

ll count=0;

while(pq.size()>1)

{

pair p1 = pq.top();

pq.pop();

pair p2 = pq.top();

pq.pop();

ll val1=p1.second;

ll val2=p2.second;

val1–;

val2–;

count+=1;

if(val1!=0)

pq.push({p1.first,val1});

if(val2!=0)

pq.push({p2.first,val2});

}

if(pq.size()==1)

{

pair p = pq.top();

count+=p.second;

}

cout<<count<<endl;

}

return 0;

}