#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define forn(a,n) for(ll i=a;i<n;i++ )
int left(int si){return (si<<1)+1;}
int right(int si) {return (si<<1)+2;}

int solve(ll n)
{
  int arr[2*n];
  forn(0,2*n)
    cin>>arr[i];
    sort(arr,arr+2*n);
    int sum=arr[0]+arr[1];
    cout<<1<<" "<<2<<endl;
    queue<int>res[sum];
    forn(2,2*n)
        res[arr[i]%sum].push(i);
    while(res[0].size()%2&&!res[0].empty())
    {
        int u=res[0].front();
        res[0].pop();
        int v=res[0].front();
        res[0].pop();
        cout<<u+1<<" "<<v+1<<endl;
    }
    for(int i=1;i<=sum/2;i++)
    {
        int a=i,b=sum-i;
        while(!res[a].empty()&&!res[b].empty())
        {
         int u=res[a].front();
        res[a].pop();
        int v=res[b].front();
        res[b].pop();
        cout<<u+1<<" "<<v+1<<endl;
        }
    }
}
int main(){
int t;
cin>>t;
while(t--){
    ll k;
    cin>>k;
    solve(k);
}
}


#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define forn(a,n) for(ll i=a;i<n;i++ )
int left(int si){return (si<<1)+1;}
int right(int si) {return (si<<1)+2;}

int solve(ll n)
{
  int arr[2*n];
  forn(0,2*n)
    cin>>arr[i];
    sort(arr,arr+2*n);
    int sum=arr[0]+arr[1];
    cout<<arr[0]<<" "<<arr[1]<<endl;
    queue<int>res[sum];
    forn(2,2*n)
        res[arr[i]%sum].push(i);
    while(res[0].size()%2&&!res[0].empty())
    {
        int u=res[0].front();
        res[0].pop();
        int v=res[0].front();
        res[0].pop();
        cout<<arr[u]<<" "<<arr[v]<<endl;
    }
    for(int i=1;i<=sum/2;i++)
    {
        int a=i,b=sum-i;
        while(!res[a].empty()&&!res[b].empty())
        {
         int u=res[a].front();
        res[a].pop();
        int v=res[b].front();
        res[b].pop();
        cout<<arr[u]<<" "<<arr[v]<<endl;
        }
    }
}
int main(){
int t;
cin>>t;
while(t--){
    ll k;
    cin>>k;
    solve(k);
}
}


#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define forn(a,n) for(ll i=a;i<n;i++ )
int left(int si){return (si<<1)+1;}
int right(int si) {return (si<<1)+2;}

void solve(ll n)
{
  int arr[2*n];
  forn(0,2*n)
    {
        cin>>arr[i];

    }
    int sum=arr[0]+arr[1];
    cout<<1<<" "<<2<<endl;
    queue<int>res[sum];
    forn(2,2*n)
        {

            int u=arr[i]%sum;
            res[u].push(i);
        }
  int d=n-2;
    while(res[0].size()%2==0&&!res[0].empty()&&d--)
    {
        int u=res[0].front();
        res[0].pop();
        int v=res[0].front();
        res[0].pop();
        cout<<u+1<<" "<<v+1<<endl;
    }
    for(int i=1;i<=sum/2;i++)
    {
        int a=i,b=sum-i;
        while(!res[a].empty()&&!res[b].empty()&&d--)
        {
         int u=res[a].front();
        res[a].pop();
        int v=res[b].front();
        res[b].pop();
        cout<<u+1<<" "<<v+1<<endl;
        }
    }
}
int main(){
int t;
cin>>t;
while(t--){
    ll k;
    cin>>k;
    solve(k);
}
}


#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define forn(a,n) for(ll i=a;i<n;i++ )
int left(int si){return (si<<1)+1;}
int right(int si) {return (si<<1)+2;}

int solve(ll n)
{
  int arr[2*n];
  forn(0,2*n)
    cin>>arr[i];
    sort(arr,arr+2*n);
    int sum=arr[0]+arr[1];
    cout<<0<<" "<<1<<endl;
    queue<int>res[sum];
    forn(2,2*n)
        res[arr[i]%sum].push(i);
    while(res[0].size()%2&&!res[0].empty())
    {
        int u=res[0].front();
        res[0].pop();
        int v=res[0].front();
        res[0].pop();
        cout<<u<<" "<<v<<endl;
    }
    for(int i=1;i<=sum/2;i++)
    {
        int a=i,b=sum-i;
        while(!res[a].empty()&&!res[b].empty())
        {
         int u=res[a].front();
        res[a].pop();
        int v=res[b].front();
        res[b].pop();
        cout<<u<<" "<<v<<endl;
        }
    }
}
int main(){
int t;
cin>>t;
while(t--){
    ll k;
    cin>>k;
    solve(k);
}
}


#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define forn(a,n) for(ll i=a;i<n;i++ )
int left(int si){return (si<<1)+1;}
int right(int si) {return (si<<1)+2;}

void solve(ll n)
{
  int arr[2*n];
  forn(0,2*n)
    {
        cin>>arr[i];

    }
    int sum=2;
    queue<int>res[sum];
    forn(0,2*n)
        {

            int u=arr[i]%sum;
            res[u].push(i);
        }
  int d=n-1;
    while(res[0].size()>=2&&!res[0].empty()&&d--)
    {
        int u=res[0].front();
        res[0].pop();
        int v=res[0].front();
        res[0].pop();
        cout<<u+1<<" "<<v+1<<endl;
    }
   while(res[1].size()>=2&&!res[1].empty()&&d--)
    {
        int u=res[1].front();
        res[1].pop();
        int v=res[1].front();
        res[1].pop();
        cout<<u+1<<" "<<v+1<<endl;
    }
}
int main(){
int t;
cin>>t;
while(t--){
    ll k;
    cin>>k;
    solve(k);
}
}


#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define forn(a,n) for(ll i=a;i<n;i++ )
int left(int si){return (si<<1)+1;}
int right(int si) {return (si<<1)+2;}

void solve(ll n)
{
  int arr[2*n];
  forn(0,2*n)
    cin>>arr[i];
    sort(arr,arr+2*n);
    int sum=arr[0]+arr[1];
    cout<<1<<" "<<2<<endl;
    queue<int>res[sum];
    forn(2,2*n)
        {

            int u=arr[i]%sum;
            res[u].push(i);
        }
  int d=n-2;
    while(res[0].size()%2==0&&!res[0].empty()&&d--)
    {
        int u=res[0].front();
        res[0].pop();
        int v=res[0].front();
        res[0].pop();
        cout<<u+1<<" "<<v+1<<endl;
    }
    for(int i=1;i<=sum/2;i++)
    {
        int a=i,b=sum-i;
        while(!res[a].empty()&&!res[b].empty()&&d--)
        {
         int u=res[a].front();
        res[a].pop();
        int v=res[b].front();
        res[b].pop();
        cout<<u+1<<" "<<v+1<<endl;
        }
    }
}
int main(){
int t;
cin>>t;
while(t--){
    ll k;
    cin>>k;
    solve(k);
}
}


#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define forn(a,n) for(ll i=a;i<n;i++ )
int left(int si){return (si<<1)+1;}
int right(int si) {return (si<<1)+2;}

void solve(ll n)
{
  int arr[2*n];
  forn(0,2*n)
    {
        cin>>arr[i];

    }
    int sum=arr[0]+arr[1];
    cout<<1<<" "<<2<<endl;
    queue<int>res[sum];
    forn(2,2*n)
        {

            int u=arr[i]%sum;
            res[u].push(i);
        }
  int d=n-2;
    while(res[0].size()%2==0&&!res[0].empty()&&d--)
    {
        int u=res[0].front();
        res[0].pop();
        int v=res[0].front();
        res[0].pop();
        cout<<u+1<<" "<<v+1<<endl;
    }
    for(int i=1;i<=sum/2;i++)
    {
        int a=i,b=sum-i;
        while(!res[a].empty()&&!res[b].empty()&&d--)
        {
         int u=res[a].front();
        res[a].pop();
        int v=res[b].front();
        res[b].pop();
       cout<<u+1<<" "<<v+1<<endl;
        }
    }
}
int main(){
int t;
cin>>t;
while(t--){
    ll k;
    cin>>k;
    solve(k);
}
}


#include<iostream>
#include <vector>
using namespace std;

void printIdx(vector<int> &v, int i){
    cout<<v[i]+1<<" "<<v[i+1]+1<<endl;
}

int main(){
    int c, n;
    int a[1000];
    cin >> c;
    for(int i=0; i<c; i++){
        cin>>n;
        vector<int> oddIdx;
        vector<int> evenIdx;
        for(int i=0; i<2*n; i++){
            cin >> a[i];
            if(a[i]%2!=0){
                oddIdx.push_back(i);
            }else{
                evenIdx.push_back(i);
            }
        }
        if(oddIdx.size()>0 and evenIdx.size()>0){
            if(oddIdx.size()%2==1 || evenIdx.size()%2==1){
                oddIdx.pop_back();
                evenIdx.pop_back();
            }else if(oddIdx.size()>=2){
                oddIdx.pop_back();
                oddIdx.pop_back();
            }else{
                evenIdx.pop_back();
                evenIdx.pop_back();
            }
            for(int i=0; i<oddIdx.size(); i+=2){
                printIdx(oddIdx, i);
            }
            for(int i=0; i<evenIdx.size(); i+=2){
                printIdx(evenIdx, i);
            }
        }else if(oddIdx.size()>0){
            for(int i=0; i<oddIdx.size()-2; i+=2){
                printIdx(oddIdx, i);
            }
        }else{
            for(int i=0; i<evenIdx.size()-2; i+=2){
                printIdx(evenIdx, i);
            }
        }
    }
    return 0;
}


#include<iostream>
#include <vector>
using namespace std;

int main(){
    int c, n;
    int a[1000];
    cin >> c;
    for(int i=0; i<c; i++){
        cin>>n;
        vector<int> oddIdx;
        vector<int> evenIdx;
        for(int i=0; i<2*n; i++){
            cin >> a[i];
            if(a[i]%2!=0){
                oddIdx.push_back(i);
            }else{
                evenIdx.push_back(i);
            }
        }
        if(oddIdx.size()%2==0 && evenIdx.size()%2==0){
            int evneHalf = evenIdx.size()/2;
            int oddHalf = oddIdx.size()/2;
            for(int i=0; i<evneHalf; i++){
                cout << evenIdx[i]+1 << " " << evenIdx[i+evneHalf]+1 << endl;
            }
            for(int i=0; i<oddHalf-1; i++){
                cout << oddIdx[i]+1 << " " << oddIdx[i+oddHalf]+1 << endl;
            }
        }else{
            // both len are odd
            int evneHalf = evenIdx.size()/2;
            int oddHalf = oddIdx.size()/2;
            for(int i=0; i<evneHalf; i++){
                cout << evenIdx[i]+1 << " " << evenIdx[i+evneHalf]+1 << endl;
            }
            for(int i=0; i<oddHalf; i++){
                cout << oddIdx[i]+1 << " " << oddIdx[i+oddHalf]+1 << endl;
            }
        }
    }
    return 0;
}


#include<iostream>
#include <vector>
using namespace std;

int main(){
    vector<int> oddIdx;
    vector<int> evenIdx;
    int c, n;
    cin >> c;
    for(int i=0; i<c; i++){
        cin>>n;
        oddIdx.clear();
        evenIdx.clear();
        for(int i=0; i<2*n; i++){
            int a;
            cin >> a;
            if(a%2!=0){
                oddIdx.push_back(i);
            }else{
                evenIdx.push_back(i);
            }
        }
        if(oddIdx.size()%2==0 && evenIdx.size()%2==0){
            if(oddIdx.size()>=2){
                oddIdx.pop_back();
                oddIdx.pop_back();
            }else{
                evenIdx.pop_back();
                evenIdx.pop_back();
            }
        }
        if(oddIdx.size()>0){
            for(int i=0; i<oddIdx.size()-1; i+=2){
                cout<<oddIdx[i]+1<<" "<<oddIdx[i+1]+1<<endl;
            }
        }
        if(evenIdx.size()>0){
            for(int i=0; i<evenIdx.size()-1; i+=2){
                cout<<evenIdx[i]+1<<" "<<evenIdx[i+1]+1<<endl;
            }
        }
    }
    return 0;
}


#include<iostream>
#include <vector>
using namespace std;

int main(){
    int c, n;
    int a[1000];
    cin >> c;
    for(int i=0; i<c; i++){
        cin>>n;
        vector<int> oddIdx;
        vector<int> evenIdx;
        for(int i=0; i<2*n; i++){
            cin >> a[i];
            if(a[i]%2!=0){
                oddIdx.push_back(i);
            }else{
                evenIdx.push_back(i);
            }
        }
        if(oddIdx.size()%2==0 && evenIdx.size()%2==0){
            int evneHalf = evenIdx.size()/2;
            int oddHalf = oddIdx.size()/2;
            if(oddIdx.size()==0){
                for(int i=0; i<evneHalf-1; i++){
                    cout << evenIdx[i]+1 << " " << evenIdx[i+evneHalf]+1 << endl;
                }
            }else if(evenIdx.size()==0){
                for(int i=0; i<oddHalf-1; i++){
                    cout << oddIdx[i]+1 << " " << oddIdx[i+oddHalf]+1 << endl;
                }
            }else{
                for(int i=0; i<evneHalf; i++){
                    cout << evenIdx[i]+1 << " " << evenIdx[i+evneHalf]+1 << endl;
                }
                for(int i=0; i<oddHalf-1; i++){
                    cout << oddIdx[i]+1 << " " << oddIdx[i+oddHalf]+1 << endl;
                }
            }
        }else{
            // both len are odd
            int evneHalf = evenIdx.size()/2;
            int oddHalf = oddIdx.size()/2;
            for(int i=0; i<evneHalf; i++){
                cout << evenIdx[i]+1 << " " << evenIdx[i+evneHalf]+1 << endl;
            }
            for(int i=0; i<oddHalf; i++){
                cout << oddIdx[i]+1 << " " << oddIdx[i+oddHalf]+1 << endl;
            }
        }
        cout << endl;
    }
    return 0;
}


#include<iostream>
#include <vector>
using namespace std;

void printIdx(vector<int> &v, int i){
    cout<<v[i]+1<<" "<<v[i+1]+1<<endl;
}

int main(){
    int c, n;
    cin >> c;
    for(int i=0; i<c; i++){
        cin>>n;
        vector<int> oddIdx;
        vector<int> evenIdx;
        for(int i=0; i<2*n; i++){
            int a;
            cin >> a;
            if(a%2!=0){
                oddIdx.push_back(i);
            }else{
                evenIdx.push_back(i);
            }
        }
        if(oddIdx.size()%2==0 && evenIdx.size()%2==0){
            oddIdx.pop_back();
            oddIdx.pop_back();
        }
        for(int i=0; i<oddIdx.size()-1; i+=2){
            printIdx(oddIdx, i);
        }
        for(int i=0; i<evenIdx.size()-1; i+=2){
            printIdx(evenIdx, i);
        }
    }
    return 0;
}


#include<iostream>
#include <vector>
using namespace std;

void printIdx(vector<int> &v, int i){
    cout<<v[i]+1<<" "<<v[i+1]+1<<endl;
}

int main(){
    int c, n;
    cin >> c;
    for(int i=0; i<c; i++){
        cin>>n;
        vector<int> oddIdx;
        vector<int> evenIdx;
        for(int i=0; i<2*n; i++){
            int a;
            cin >> a;
            if(a%2!=0){
                oddIdx.push_back(i);
            }else{
                evenIdx.push_back(i);
            }
        }
        for(int i=0; i<oddIdx.size()-1; i+=2){
            printIdx(oddIdx, i);
        }
        for(int i=0; i<evenIdx.size()-1; i+=2){
            printIdx(evenIdx, i);
        }
    }
    return 0;
}


#include<iostream>
#include <vector>
using namespace std;

int main(){
    int c, n;
    int a[1000];
    cin >> c;
    for(int i=0; i<c; i++){
        cin>>n;
        vector<int> oddIdx;
        vector<int> evenIdx;
        for(int i=0; i<2*n; i++){
            cin >> a[i];
            if(a[i]%2!=0){
                oddIdx.push_back(i);
            }else{
                evenIdx.push_back(i);
            }
        }
        if(oddIdx.size()%2==0 && evenIdx.size()%2==0){
            int evneHalf = evenIdx.size()/2;
            int oddHalf = oddIdx.size()/2;
            for(int i=0; i<evneHalf; i++){
                cout << evenIdx[i] << " " << evenIdx[i+evneHalf] << endl;
            }
            for(int i=0; i<oddHalf-1; i++){
                cout << oddIdx[i] << " " << oddIdx[i+oddHalf] << endl;
            }
        }else{
            // both len are odd
            int evneHalf = evenIdx.size()/2;
            int oddHalf = oddIdx.size()/2;
            for(int i=0; i<evneHalf; i++){
                cout << evenIdx[i] << " " << evenIdx[i+evneHalf] << endl;
            }
            for(int i=0; i<oddHalf; i++){
                cout << oddIdx[i] << " " << oddIdx[i+oddHalf] << endl;
            }
        }
    }
    return 0;
}


#include<iostream>
#include <vector>
using namespace std;

int main(){
    vector<int> oddIdx;
    vector<int> evenIdx;
    int c, n;
    cin >> c;
    for(int i=0; i<c; i++){
        cin>>n;
        oddIdx.clear();
        evenIdx.clear();
        for(int i=0; i<2*n; i++){
            int a;
            cin >> a;
            if(a%2!=0){
                oddIdx.push_back(i);
            }else{
                evenIdx.push_back(i);
            }
        }
        if(oddIdx.size()%2==0 && evenIdx.size()%2==0){
            if(oddIdx.size()>=2){
                oddIdx.pop_back();
                oddIdx.pop_back();
            }else{
                evenIdx.pop_back();
                evenIdx.pop_back();
            }
        }
        for(int i=0; i< ((int) oddIdx.size())-1; i+=2){
            cout<<oddIdx[i]+1<<" "<<oddIdx[i+1]+1<<endl;
        }
        for(int i=0; i< ((int) evenIdx.size())-1; i+=2){
            cout<<evenIdx[i]+1<<" "<<evenIdx[i+1]+1<<endl;
        }
    }
    return 0;
} // g++ -std=c++11 A.cpp -o A && ./A < in


#include<iostream>
#include <vector>
using namespace std;

void printIdx(vector<int> v, int i){
    cout<<v[i]+1<<" "<<v[i+1]+1<<endl;
}

int main(){
    int c, n;
    int a[1000];
    cin >> c;
    for(int i=0; i<c; i++){
        cin>>n;
        vector<int> oddIdx;
        vector<int> evenIdx;
        for(int i=0; i<2*n; i++){
            cin >> a[i];
            if(a[i]%2!=0){
                oddIdx.push_back(i);
            }else{
                evenIdx.push_back(i);
            }
        }
        if(oddIdx.size()>0 and evenIdx.size()>0){
            if(oddIdx.size()==1 || evenIdx.size()==1){
                oddIdx.pop_back();
                evenIdx.pop_back();
            }else{
                oddIdx.pop_back();
                oddIdx.pop_back();
            }
            for(int i=0; i<oddIdx.size(); i+=2){
                printIdx(oddIdx, i);
            }
            for(int i=0; i<evenIdx.size(); i+=2){
                printIdx(evenIdx, i);
            }
        }else if(oddIdx.size()>0){
            for(int i=0; i<oddIdx.size()-2; i+=2){
                printIdx(oddIdx, i);
            }
        }else{
            for(int i=0; i<evenIdx.size()-2; i+=2){
                printIdx(evenIdx, i);
            }
        }
    }
    return 0;
}


#include<iostream>
#include <vector>
using namespace std;

int main(){
    int c, n;
    int a[1000];
    cin >> c;
    for(int i=0; i<c; i++){
        cin>>n;
        vector<int> oddIdx;
        vector<int> evenIdx;
        for(int i=0; i<2*n; i++){
            cin >> a[i];
            if(a[i]%2!=0){
                oddIdx.push_back(i);
            }else{
                evenIdx.push_back(i);
            }
        }
        if(oddIdx.size()%2==0 && evenIdx.size()%2==0){
            int evneHalf = evenIdx.size()/2;
            int oddHalf = oddIdx.size()/2;
            for(int i=0; i<evneHalf; i++){
                cout << a[evenIdx[i]] << " " << a[evenIdx[i+evneHalf]] << endl;
            }
            for(int i=0; i<oddHalf-1; i++){
                cout << a[oddIdx[i]] << " " << a[oddIdx[i+oddHalf]] << endl;
            }
        }else{
            // both len are odd
            int evneHalf = evenIdx.size()/2;
            int oddHalf = oddIdx.size()/2;
            for(int i=0; i<evneHalf; i++){
                cout << evenIdx[i] << " " << evenIdx[i+evneHalf] << endl;
            }
            for(int i=0; i<oddHalf; i++){
                cout << oddIdx[i] << " " << oddIdx[i+oddHalf] << endl;
            }
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main(){
ios::sync_with_stdio(0);
cin.tie(0);
 int t;
 cin>>t;
 while (t)
 { t--;
   int n;
   cin>>n;
   vector<int> a(n);
   int sum=0;
   for (size_t i = 0; i < n; i++)
   {
     cin>>a[i];

     sum+=a[i];
   }
int count=0;
size_t i = 0;
   for (; (i < n )&&(count<n/2-1); i++)
   {if(a[i]==-1)
      continue;

     if(a[i]%2==0)
     {
       for (size_t j = i+1; j < n; j++)
       {
         if(a[j]%2==0 && a[j]!=-1)
         {
           cout<<i+1<<" "<<j+1<<'\n';
            a[j]=-1;
            a[i]=-1;
            count++;
            break;

         }

       }

     }
     else
     {
       for (size_t j = i+1; j < n; j++)
       {
         if(a[j]%2!=0 && a[j]!=-1)
         {
           cout<<i+1<<" "<<j+1<<'\n';
            a[j]=-1;
            a[i]=-1;
            count++;
            break;
         }

     }

   }

 }
 }

return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main(){
ios::sync_with_stdio(0);
cin.tie(0);
 int t;
 cin>>t;
 while (t)
 { t--;
   int n;
   cin>>n;
   vector<int> odd,even;
   int tmp;
   for (size_t i = 0; i < 2*n; i++)
   {
     cin>>tmp;
     if(tmp%2==0)
     {
       even.push_back(i+1);

     }
     else
     {
       odd.push_back(i+1);
     }

   }
   tmp=0;
   int count=0;
  /* for (size_t i = 0; i < even.size(); i++)
   {
     cout<<"EVen"<<even[i];
   }
   for (size_t i = 0; i < odd.size(); i++)
   {
     cout<<"Odd"<<odd[i];
   }
   */

   while (tmp+1<odd.size() &&count<n-1)
   {
     count++;
    cout<<odd[tmp]<<" "<<odd[tmp+1]<<'\n';
    tmp+=2;
   }
   tmp=0;
   while (tmp+1<even.size() && count<n-1)
   {
     count++;
     cout<<even[tmp]<<" "<<even[tmp+1]<<'\n';
     tmp+=2;

   }
 }

return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main(){
ios::sync_with_stdio(0);
cin.tie(0);
 int t;
 cin>>t;
 while (t)
 { t--;
   int n;
   cin>>n;
   vector<int> odd,even;
   int tmp;
   for (size_t i = 0; i < 2*n; i++)
   {
     cin>>tmp;
     if(tmp%2==0)
     {
       even.push_back(i+1);

     }
     else
     {
       odd.push_back(i+1);
     }

   }
   tmp=0;
   int count=0;
  /* for (size_t i = 0; i < even.size(); i++)
   {
     cout<<"EVen"<<even[i];
   }
   for (size_t i = 0; i < odd.size(); i++)
   {
     cout<<"Odd"<<odd[i];
   }
   */

   while (tmp+1<odd.size() &&count<n)
   {
     count++;
    cout<<odd[tmp]<<" "<<odd[tmp+1]<<'\n';
    tmp+=2;
   }
   tmp=0;
   while (tmp+1<even.size() && count<n)
   {
     count++;
     cout<<even[tmp]<<" "<<even[tmp+1]<<'\n';
     tmp+=2;

   }
 }

return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main(){
ios::sync_with_stdio(0);
cin.tie(0);
 int t;
 cin>>t;
 while (t)
 { t--;
   int n;
   cin>>n;
   vector<int> odd,even;
   int tmp;
   for (size_t i = 0; i < n; i++)
   {
     cin>>tmp;
     if(tmp%2)
     {
       even.push_back(i);

     }
     else
     {
       odd.push_back(i);
     }

   }
   tmp=0;
   int count=0;
   while (tmp+1<odd.size())
   {
     count++;
    cout<<odd[tmp]<<" "<<odd[tmp+1]<<'\n';
    tmp+=2;
   }
   tmp=0;
   while (tmp+1<even.size() && count<=n/2-1)
   {
     count++;
     cout<<even[tmp]<<" "<<even[tmp+1]<<'\n';
     tmp+=2;

   }
 }

return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main(){
ios::sync_with_stdio(0);
cin.tie(0);
 int t;
 cin>>t;
 while (t)
 { t--;
   int n;
   cin>>n;
   vector<int> odd,even;
   int tmp;
   for (size_t i = 0; i < 2*n; i++)
   {
     cin>>tmp;
     if(tmp%2==0)
     {
       even.push_back(i+1);

     }
     else
     {
       odd.push_back(i+1);
     }

   }
   tmp=0;
   int count=0;
  /* for (size_t i = 0; i < even.size(); i++)
   {
     cout<<"EVen"<<even[i];
   }
   for (size_t i = 0; i < odd.size(); i++)
   {
     cout<<"Odd"<<odd[i];
   }
   */

   while (tmp+1<odd.size() &&count<n)
   {
     count++;
    cout<<odd[tmp]<<" "<<odd[tmp+1]<<'\n';
    tmp+=2;
   }
   tmp=0;
   while (tmp+1<even.size() && count<n-1)
   {
     count++;
     cout<<even[tmp]<<" "<<even[tmp+1]<<'\n';
     tmp+=2;

   }
 }

return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main(){
ios::sync_with_stdio(0);
cin.tie(0);
 int t;
 cin>>t;
 while (t)
 { t--;
   int n;
   cin>>n;
   vector<int> odd,even;
   int tmp;
   for (size_t i = 0; i < n; i++)
   {
     cin>>tmp;
     if(tmp%2)
     {
       even.push_back(i);

     }
     else
     {
       odd.push_back(i);
     }

   }
   tmp=0;
   int count=0;
   while (tmp+1<odd.size())
   {
     count++;
    cout<<1+odd[tmp]<<" "<<1+odd[tmp+1]<<'\n';
    tmp+=2;
   }
   tmp=0;
   while (tmp+1<even.size() && count<=n/2-1)
   {
     count++;
     cout<<1+even[tmp]<<" "<<1+even[tmp+1]<<'\n';
     tmp+=2;

   }
 }

return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main(){
ios::sync_with_stdio(0);
cin.tie(0);
 int t;
 cin>>t;
 while (t)
 { t--;
   int n;
   cin>>n;
   vector<int> odd,even;
   int tmp;
   for (size_t i = 0; i < 2*n; i++)
   {
     cin>>tmp;
     if(tmp%2==0)
     {
       even.push_back(i+1);

     }
     else
     {
       odd.push_back(i+1);
     }

   }
   tmp=0;
   int count=0;
  /* for (size_t i = 0; i < even.size(); i++)
   {
     cout<<"EVen"<<even[i];
   }
   for (size_t i = 0; i < odd.size(); i++)
   {
     cout<<"Odd"<<odd[i];
   }
   */

   while (tmp+1<odd.size())
   {
     count++;
    cout<<odd[tmp]<<" "<<odd[tmp+1]<<'\n';
    tmp+=2;
   }
   tmp=0;
   while (tmp+1<even.size())
   {
     count++;
     cout<<even[tmp]<<" "<<even[tmp+1]<<'\n';
     tmp+=2;

   }
 }

return 0;
}


#include<bits/stdc++.h>
using namespace std;
int T,n,a[200010];

int main(){
	scanf("%d",&T);
	while(T--){
		scanf("%d",&n);int ans=0;
		n=n+n;vector<int>v1,v2;
		for(int i=1;i<=n;++i)scanf("%d",&a[i]);
		for(int i=1;i<=n;++i){
			if(a[i]&1)v1.push_back(i);
			else v2.push_back(i);
		}
		n/=2;
		int len=(int)v1.size();
		if(len&1)v1.pop_back(),len--;
		for(int i=0;i<len&&ans<n-1;i+=2){
			cout<<v1[i]<<" "<<v1[i+1]<<endl;
			ans++;
		}
		len=(int)v2.size();
		if(len&1)len--,v2.pop_back();
		for(int i=0;i<len&&ans<n-1;i+=2){
			cout<<v2[i]<<" "<<v2[i+1]<<endl;
			ans++;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int T,n,a[200010];

int main(){
	scanf("%d",&T);
	while(T--){
		scanf("%d",&n);int ans=0;
		n=n+n;vector<int>v1,v2;
		for(int i=1;i<=n;++i)scanf("%d",&a[i]);
		for(int i=1;i<=n;++i){
			if(a[i]&1)v1.push_back(i);
			else v2.push_back(i);
		}
		n/=2;
		int len=(int)v1.size();ans+=len/2;
		if(len&1)v1.pop_back(),len--;
		for(int i=0;i<len;i+=2){
			cout<<v1[i]<<" "<<v1[i+1]<<endl;
		}
		len=(int)v2.size();
		if(len&1)len--,v2.pop_back();
		for(int i=0;i<len&&ans<n-1;i+=2){
			cout<<v2[i]<<" "<<v2[i+1]<<endl;
			ans++;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int T,n,a[200010];

int main(){
	scanf("%d",&T);
	while(T--){
		scanf("%d",&n);int ans=0;
		n=n+n;vector<int>v1,v2;
		for(int i=1;i<=n;++i)scanf("%d",&a[i]);
		for(int i=1;i<=n;++i){
			if(a[i]&1)v1.push_back(i);
			else v2.push_back(i);
		}
		n/=2;
		int len=(int)v1.size();ans+=len/2;
		if(len&1)v1.pop_back(),len--;
		for(int i=0;i<len;i+=2){
			cout<<v1[i]<<" "<<v1[i+1]<<endl;
		}
		len=(int)v2.size();if(len&1)len--,v2.pop_back();
		for(int i=0;i<len&&ans<n-1;++i){
			cout<<v2[i]<<" "<<v2[i+1]<<endl;
			ans++;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int T,n,a[200010];

int main(){
	scanf("%d",&T);
	while(T--){
		scanf("%d",&n);int ans=0;
		n=n+n;vector<int>v1,v2;
		for(int i=1;i<=n;++i)scanf("%d",&a[i]);
		for(int i=1;i<=n;++i){
			if(a[i]&1)v1.push_back(i);
			else v2.push_back(i);
		}
		n/=2;
		int len=(int)v1.size();ans+=len/2;
		if(len&1)v1.pop_back(),len--;
		for(int i=0;i<len;i+=2){
			cout<<v1[i]<<" "<<v1[i+1]<<endl;
		}
		len=(int)v2.size();
		for(int i=0;i<v2.size()&&ans<n-1;++i){
			cout<<v2[i]<<" "<<v2[i+1]<<endl;
			ans++;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define loop(i,k,n) for(int i=k;i<n;++i)
#define int long long int
const int N = 1e5+5;

int32_t main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t;
    cin>>t;

    while(t--)
    {
        int n;
        cin>>n;

        vector<int> v(2*n);
        vector<int> even;
        vector<int> odd;
        for(int i=0;i<2*n;i++)
        {
            cin>>v[i];

            if(v[i]%2)
            {
                odd.push_back(i);
            }
            else
            {
                even.push_back(i);
            }
        }

        int cnt = 0;
        for(int i=0;i<even.size()-1;i++)
        {
            if(cnt>=n-1)
            {
                break;
            }

            cout<<even[i]+1<<" "<<even[i+1]+1<<endl;
            cnt++;
            i++;
        }

        for(int i=0;i<odd.size()-1;i++)
        {
            if(cnt>=n-1)
            {
                break;
            }

            cout<<odd[i]+1<<" "<<odd[i+1]+1<<endl;
            cnt++;
            i++;
        }
    }
}


#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ff first
#define ss second
#define loop(i,k,n) for(int i=k;i<n;++i)
#define rloop(i,n,k) for(int i=n;i>=k;i--)
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define all(v) v.begin(),v.end()
#define mset(a,i) memset(a,i,sizeof(a))
#define mii map<int,int>
#define pii pair<int,int>

#define mp make_pair
#define pb push_back

void get_it_done(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

const int N = 3e5+5;
int arr[3005][3005];
bool isPrime(int n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0) return 1;
    }
    return 0;
}

void hardev(){
    int n;
    cin>>n;
    vi a(2*n+1);
    bool viisisiis[2005];
    mset(viisisiis,0);
    loop(i,1,2*n+1) cin>>a[i];
    vpii hey;
    if(n==2){
        cout<<1<<" "<<2<<endl;
        return;
    }
    loop(i,1,2*n+1){
        loop(j,i+1,2*n+1){
            int sum = a[i]+a[j];
            if(!(sum&1) && !viisisiis[i] && !viisisiis[j] && (hey.size())<(n-1)){
                hey.pb({i,j});
                viisisiis[i] = 1;
                viisisiis[j] = 1;
                break;
            }
        }
    }
    loop(i,0,hey.size()){
        cout<<hey[i].ff<<" "<<hey[i].ss<<endl;
    }

}

int32_t main(){
    get_it_done();
    int tc=1;
    cin >> tc;
    while (tc--){
        hardev();
    }
}


#include<bits/stdc++.h>
using namespace std;

#define loop(i,k,n) for(int i=k;i<n;++i)
#define int long long int
const int N = 1e5+5;

int32_t main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t;
    cin>>t;

    while(t--)
    {
        int n;
        cin>>n;

        vector<int> a(2*n);

        vector<int> evena;
        vector<int> odda;
        for(int i=0;i<2*n;i++)
        {
            int ab;
            cin>>ab;
            if(ab%2==0)
            {
                evena.push_back(i);
            }
            else
            {
                odda.push_back(i);
            }
        }
        int count = 0;

        for(int i=0;i+1<evena.size()&&count<n-1;i+=2)
        {
            cout<<evena[i]+1<<" "<<evena[i+1]+1<<endl;
            count++;
        }

        for(int i=0;i+1<odda.size()&&count<n-1;i+=2)
        {
            cout<<odda[i]+1<<" "<<odda[i+1]+1<<endl;
            count++;
        }

    }
}


#include<bits/stdc++.h>
using namespace std;

#define loop(i,k,n) for(int i=k;i<n;++i)
#define int long long int
const int N = 1e5+5;

int32_t main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t;
    cin>>t;

    while(t--)
    {
        int n;
        cin>>n;
        int k = 2*n;
        vector<int> a(k);
        int odd = 0;
        int even = 0;
        vector<int> evena;
        vector<int> odda;
        for(int i=0;i<k;i++)
        {
            cin>>a[i];
            if(a[i]%2==0)
            {
                evena.push_back(i);
            }
            else
            {
                odda.push_back(i);
                odd++;
            }
        }

        int cnt = 0;
        for(int i=0;i<evena.size()-1;i+=2)
        {
            if(cnt>=n-1)
            {
                break;
            }
            cout<<evena[i]+1<<" "<<evena[i+1]+1<<endl;
            cnt++;
        }

        for(int i=0;i<odda.size()-1;i+=2)
        {
            if(cnt>=n-1)
            {
                break;
            }
            cout<<odda[i]+1<<" "<<odda[i+1]+1<<endl;
            cnt++;
        }

    }
}


#include <bits/stdc++.h>
using namespace std;

#define endl "\n"
#define all(V) V.begin(),V.end()
#define see(x) cerr << #x << " = " << x << "\n";
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 1e5 + 5;

int a[ 10 ];
vector <int> V = { 4 , 8 , 15 , 16 , 23 , 42 };

bool ok( vector <int> X ) {
        sort( X.begin() , X.end() );
        for( int i = 0; i < X.size(); i++ ) {
                if( X[i] != V[i] ) return false;
        }
        return true;
}
int main( ) {
        int bad = 0;
        vector <int> cur;
        printf("? 1 1\n");
        vector <int> x;
        int tot = 108;
        fflush(stdout);
        scanf("%d",&a[1]);
        a[1] = sqrt( a[1] );
        cur.push_back( a[1] );
        tot -= a[1];
        for( int i = 1; i <= 3; i++ ) {
                printf("? %d %d\n",i,i+1);
                fflush(stdout);
                int x;
                scanf("%d",&x);
                a[i+1] = x/a[i];
                tot -= a[i+1];
                cur.push_back( a[i+1] );
        }
        int d = a[4];
        for( int e = 0; e < V.size(); e++ ) {
                for( int f = 0; f < V.size(); f++ ) {
                        if( e == f ) continue;
                        vector <int> temp = cur;
                        if( temp[e] * ( d + temp[f] ) == tot ) {
                                temp.push_back( V[e] );
                                temp.push_back( V[f] );
                                if( ok( temp ) ) {
                                        printf("!");
                                        for( int k = 0; k < temp.size(); k++ ) {
                                            printf(" %d",temp[k]);
                                        }
                                        printf("\n");
                                        fflush(stdout);
                                        return 0;
                                }
                        }
                }
        }
        assert( false );
        return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define endl "\n"
#define all(V) V.begin(),V.end()
#define see(x) cerr << #x << " = " << x << "\n";
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 1e5 + 5;

int a[ 10 ];
vector <int> V = { 4 , 8 , 15 , 16 , 23 , 42 };

bool ok( vector <int> X ) {
        sort( X.begin() , X.end() );
        if( X == V ) return true;
        else return false;
}
int main( ) {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        #ifdef OFFLINE
            //freopen( "input.txt" , "r" , stdin );
        #endif // OFFLINE
        int bad = 0;
        vector <int> cur;
        for( int i = 1; i <= 4; i++ ) {
                cout << "? " << i << " " << i << endl;
                int x;
                cin >> x;
                a[i] = x;
                bad += a[i];
                cur.push_back( a[i] );
        }
        int rem = 108 - bad;
        for( int i = 1; i <= rem; i++ ) {
                for( int j = 1; j <= rem; j++ ) {
                        if( (i + j) != rem ) continue;
                        vector <int> temp = cur;
                        temp.push_back( i );
                        temp.push_back( j );
                        if( ok( temp ) ) {
                                cout << "! ";
                                for( auto x : temp ) cout << x << " ";
                                return 0;
                        }
                }
        }
        return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define endl "\n"
#define all(V) V.begin(),V.end()
#define see(x) cerr << #x << " = " << x << "\n";
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 1e5 + 5;

int a[ 10 ];
vector <int> V = { 4 , 8 , 15 , 16 , 23 , 42 };

bool ok( vector <int> X ) {
        sort( X.begin() , X.end() );
        if( X == V ) return true;
        else return false;
}
int main( ) {
        #ifdef OFFLINE
            //freopen( "input.txt" , "r" , stdin );
        #endif // OFFLINE
        int bad = 0;
        vector <int> cur;
        for( int i = 1; i <= 4; i++ ) {
                printf("? %d %d\n",i,i);
                fflush(stdout);
                int x;
                scanf("%d",&x);
                a[i] = x;
                bad += a[i];
                cur.push_back( a[i] );
        }
        int rem = 108 - bad;
        bool done = false;
        for( int i = 1; i <= rem; i++ ) {
                for( int j = 1; j <= rem; j++ ) {
                        if( (i + j) != rem ) continue;
                        vector <int> temp = cur;
                        temp.push_back( i );
                        temp.push_back( j );
                        if( ok( temp ) ) {
                                printf("!");
                                for( int i = 0; i < temp.size(); i++ ) {
                                        printf(" %d",temp[i]);
                                }
                                printf("\n");
                                fflush(stdout);
                                done = true;
                                break;
                        }
                }
                if( done ) break;
        }
        return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define endl "\n"
#define all(V) V.begin(),V.end()
#define see(x) cerr << #x << " = " << x << "\n";
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 1e5 + 5;

int a[ 10 ];
vector <int> V = { 4 , 8 , 15 , 16 , 23 , 42 };

bool ok( vector <int> X ) {
        sort( X.begin() , X.end() );
        if( X == V ) return true;
        else return false;
}
int main( ) {
        #ifdef OFFLINE
            //freopen( "input.txt" , "r" , stdin );
        #endif // OFFLINE
        int bad = 0;
        vector <int> cur;
        for( int i = 1; i <= 4; i++ ) {
                printf("? %d %d\n",i,i);
                fflush(stdout);
                int x;
                scanf("%d",&x);
                a[i] = x;
                bad += a[i];
                cur.push_back( a[i] );
        }
        int rem = 108 - bad;
        for( int i = 1; i <= rem; i++ ) {
                for( int j = 1; j <= rem; j++ ) {
                        if( (i + j) != rem ) continue;
                        vector <int> temp = cur;
                        temp.push_back( i );
                        temp.push_back( j );
                        if( ok( temp ) ) {
                                printf("! ");
                                for( int i = 0; i < temp.size(); i++ ) {
                                        printf("%d ",temp[i]);
                                }
                                printf("\n");
                                return 0;
                        }
                }
        }
        return 0;
}


#include<bits/stdc++.h>
using namespace std;

int query(int i, int j)
{
    cout << i << " " << j << endl;
    int ans;
    cin >> ans;
    return ans;
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    vector<int> v = {4, 8, 15, 16, 23, 42};
    vector<int> a(4);

    for(int i=0; i<4; i++){
        a[i] = query(i+1, i+2);
    }
    do{
        bool can = 1;
        for(int i=0; i<4; i++){
            if(a[i] != v[i]*v[i+1]){
                can = 0;
            }
        }
        if(can == 1){
            cout << "! ";
            for(auto x: v){
                cout << x << " ";
            }
            return 0;
        }
    }
    while(next_permutation(v.begin(), v.end()));
}


#include<bits/stdc++.h>
using namespace std;

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int a[7] = {0};

    int ar, br;
    cout << "? 1" << " 2" << endl;
    cin >> ar;
    cout << "? 2" << " 3" << endl;
    cin >> br;
    a[2] = gcd(ar, br);
    a[1] = ar/a[2];
    a[3] = br/a[2];
    cout << "? 4" << " 5" << endl;
    cin >> ar;
    cout << "? 5" << " 6" << endl;
    cin >> br;
    a[5] = gcd(ar, br);
    a[3] = ar/a[5];
    a[6] = br/a[5];
    cout << "! ";
    for(int i=1; i<=6; i++){
        cout << a[i] << " ";
    }
    cout << endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int query(int i, int j)
{
    cout << "? "<< i << " " << j << endl;
    int ans;
    cin >> ans;
    return ans;
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    vector<int> v = {4, 8, 15, 16, 23, 42};
    vector<int> a(4);

    for(int i=0; i<4; i++){
        a[i] = query(i+1, i+2);
    }
    do{
        bool can = 1;
        for(int i=0; i<4; i++){
            if(a[i] != v[i]*v[i+1]){
                can = 0;
            }
        }
        if(can == 1){
            cout << "! ";
            for(auto x: v){
                cout << x << " ";
            }
            return 0;
        }
    }
    while(next_permutation(v.begin(), v.end()));
}


#include<bits/stdc++.h>
using namespace std;

int query(int i, int j)
{
    cout << i << " " << j << endl;
    int ans;
    cin >> ans;
    return ans;
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    vector<int> v = {4, 8, 15, 16, 23, 42};
    vector<int> a(4);

    for(int i=0; i<4; i++){
        a[i] = query(i+1, i+2);
    }
    do{
        bool can = 1;
        for(int i=0; i<4; i++){
            if(a[i] != v[i]*v[i+1]){
                can = 0;
            }
        }
        if(can == 1){
            cout << "! ";
            for(auto x: v){
                cout << x << " ";
            }
            return 0;
        }
    }
    while(next_permutation(v.begin(), v.end());

    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int a[7] = {0};

    int ar, br;
    cout << "?  1" <<  << " 2" << endl;
    cin >> ar;
    cout << "?  2" <<  << " 3" << endl;
    cin >> br;
    int a[2] = gcd(ar, br);
    a[1] = ar/a[2];
    a[3] = br/a[2];
    cout << "?  4" <<  << " 5" << endl;
    cin >> ar;
    cout << "?  5" <<  << " 6" << endl;
    cin >> br;
    int a[5] = gcd(ar, br);
    a[3] = ar/a[5];
    a[6] = br/a[5];
    cout << "! ";
    for(int i=1; i<=6; i++){
        cout << a[i] << " ";
    }
    cout << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int query(int middle){
    cout << middle << endl;
    string res;
    cin >> res;
    if(res == "<")
        return 1;
    else
        return 2;
}
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int ae[7] = {0};
    map<int, int> a;
    a[4] = 1;
    a[8] = 1;
    a[15] = 1;
    a[16] = 1;
    a[23] = 1;
    a[42] = 1;
    int ar, br;
    cout << "?  1" <<  << " 2" << endl;
    cin >> ar;
    cout << "?  2" <<  << " 3" << endl;
    cin >> br;
    int a[2] = gcd(ar, br);
    a[1] = ar/a[2];
    a[3] = br/a[2];
    cout << "?  4" <<  << " 5" << endl;
    cin >> ar;
    cout << "?  5" <<  << " 6" << endl;
    cin >> br;
    int a[5] = gcd(ar, br);
    a[3] = ar/a[5];
    a[6] = br/a[5];
    cout << "! ";
    for(int i=1; i<=6; i++){
        cout << a[i] << " ";
    }
    cout << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int a[7] = {0};

    int ar, br;
    cout << "? 1 2" << endl;
    cin >> ar;
    cout << "? 2 3" << endl;
    cin >> br;
    a[2] = gcd(ar, br);
    a[1] = ar/a[2];
    a[3] = br/a[2];
    cout << "? 4 5" << endl;
    cin >> ar;
    cout << "? 5 6" << endl;
    cin >> br;
    a[5] = gcd(ar, br);
    a[4] = ar/a[5];
    a[6] = br/a[5];
    cout << "! ";
    for(int i=1; i<=6; i++){
        cout << a[i] << " ";
    }
    cout << endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int query(int i, int j)
{
    cout << i << " " << j << endl;
    int ans;
    cin >> ans;
    return ans;
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    vector<int> v = {4, 8, 15, 16, 23, 42};
    vector<int> a(4);

    for(int i=0; i<4; i++){
        a[i] = query(i+1, i+2);
    }
    do{
        bool can = 1;
        for(int i=0; i<4; i++){
            if(a[i] != v[i]*v[i+1]){
                can = 0;
            }
        }
        if(can == 1){
            cout << "! ";
            for(auto x: v){
                cout << x << " ";
            }
            return 0;
        }
    }
    while(next_permutation(v.begin(), v.end()));

    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <set>

typedef long long ll;

using namespace std;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int arr[6] = {4, 8, 15, 16, 23, 42};
    pair<int, int> prr[5];
    for (int i = 1; i <= 4; i++) {
        int num;
        cout << "? " << i << " " << i + 1 << endl;
        cout << flush;
        cin >> num;
        for (int j = 0; j < 6; j++) {
            for (int k = j; k < 6; k++) {
                if (arr[j] * arr[k] == num) {
                    cout << arr[j] << " " << arr[k] << endl;
                    prr[i].first = arr[j];
                    prr[i].second = arr[k];
                }
            }
        }
    }
    if (prr[1].first == prr[2].first) {
        swap(prr[1].first, prr[1].second);
    } else if (prr[1].first == prr[2].second){
        swap(prr[1].first, prr[1].second);
        swap(prr[2].first, prr[2].second);
    } else if (prr[1].second == prr[2].second) {
        swap(prr[2].first, prr[2].second);
    }
    for (int i = 2; i <= 4; i++) {
        if (prr[i].first == prr[i - 1].first) {
            swap(prr[i].first, prr[i].second);
        }
    }
    int answer[6] = {prr[1].first};
    for (int i = 1; i <= 4; i++) {
        answer[i] = prr[i].second;
    }
    for (int i = 0; i < 6; i++) {
        bool state = true;
        for (int j = 0; j < 5; j++) {
            if (arr[i] == answer[j]) {
                state = false;
                break;
            }
        }
        if (state) {
            answer[5] = arr[i];
            break;
        }
    }
    cout << "!";
    for (int i = 0; i < 6; i++) {
        cout << " " << answer[i];
    }
    cout << endl << flush;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <set>

typedef long long ll;

using namespace std;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int arr[6] = {4, 8, 15, 16, 23, 42};
    int answer[6];
    for (int i = 1; i <= 2; i++) {
        int num;
        cout << "? " << i << " " << i << endl << flush;
        cin >> num;
        for (int a : arr) {
            if (a * a == num) {
                answer[i - 1] = a;
            }
        }
    }
    for (int i = 3; i <= 4; i++) {
        int num;
        cout << "? " << i << " " << i + 1 << endl << flush;
        cin >> num;
        for (int j = 0; j < 5; j++) {
            for (int k = j + 1; k < 6; k++) {
                if (arr[j] * arr[k] == num) {
                    answer[i * 2 - 4] = arr[j];
                    answer[i * 2 - 3] = arr[k];
                }
            }
        }
    }
    if (answer[2] == answer[5]) {
        answer[2] = answer[3];
        answer[3] = answer[5];
    } else if (answer[2] == answer[4]) {
        answer[2] = answer[3];
        answer[3] = answer[4];
        answer[4] = answer[5];
    } else if (answer[3] == answer[4]) {
        answer[4] = answer[5];
    }
    for (int a : arr) {
        if (find(answer, answer + 5, a) == answer + 5) {
            answer[5] = a;
            break;
        }
    }
    cout << "!";
    for (int a : answer) {
        cout << " " << a;
    }
    cout << endl << flush;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <set>

typedef long long ll;

using namespace std;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int arr[6] = {4, 8, 15, 16, 23, 42};
    pair<int, int> prr[5];
    for (int i = 1; i <= 4; i++) {
        int num;
        cout << "? " << i << " " << i + 1 << endl;
        cout << flush;
        cin >> num;
        for (int j = 0; j < 6; j++) {
            for (int k = 0; k < 6; k++) {
                if (arr[j] * arr[k] == num) {
                    prr[i].first = j;
                    prr[i].second = k;
                }
            }
        }
    }
    if (prr[1].first == prr[2].first) {
        swap(prr[1].first, prr[1].second);
    } else if (prr[1].first == prr[2].second){
        swap(prr[1].first, prr[1].second);
        swap(prr[2].first, prr[2].second);
    } else if (prr[1].second == prr[2].second) {
        swap(prr[2].first, prr[2].second);
    }
    for (int i = 2; i <= 4; i++) {
        if (prr[i].first == prr[i - 1].first) {
            swap(prr[i].first, prr[i].second);
        }
    }
    int answer[6] = {prr[1].first};
    for (int i = 1; i <= 4; i++) {
        answer[i] = prr[i].second;
    }
    for (int i = 0; i < 6; i++) {
        bool state = true;
        for (int j = 0; j < 5; j++) {
            if (arr[i] == answer[j]) {
                state = false;
                break;
            }
        }
        if (state) {
            answer[5] = arr[i];
            break;
        }
    }
    cout << "!";
    for (int i = 0; i < 6; i++) {
        cout << " " << answer[i];
    }
    cout << endl << flush;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <set>

typedef long long ll;

using namespace std;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int arr[6] = {4, 8, 15, 16, 23, 42};
    int answer[6];
    for (int i = 1; i <= 2; i++) {
        int num;
        cout << "? " << i << " " << i + 1 << endl << flush;
        cin >> num;
        for (int a : arr) {
            if (a * a == num) {
                answer[i - 1] = a;
            }
        }
    }
    for (int i = 3; i <= 4; i++) {
        int num;
        cout << "? " << i << " " << i + 1 << endl << flush;
        cin >> num;
        for (int j = 0; j < 5; j++) {
            for (int k = j + 1; k < 6; k++) {
                if (arr[j] * arr[k] == num) {
                    answer[i * 2 - 4] = arr[j];
                    answer[i * 2 - 3] = arr[k];
                }
            }
        }
    }
    if (answer[2] == answer[5]) {
        answer[2] = answer[3];
        answer[3] = answer[5];
    } else if (answer[2] == answer[4]) {
        answer[2] = answer[3];
        answer[3] = answer[4];
        answer[4] = answer[5];
    } else if (answer[3] == answer[4]) {
        answer[4] = answer[5];
    }
    for (int a : arr) {
        bool state = true;
        for (int j = 0; j < 5; j++) {
            if (a == answer[j]) {
                state = false;
                break;
            }
        }
        if (state) {
            answer[5] = a;
            break;
        }
    }
    cout << "!";
    for (int a : answer) {
        cout << " " << a;
    }
    cout << endl << flush;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <set>

typedef long long ll;

using namespace std;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int arr[6] = {4, 8, 15, 16, 23, 42};
    pair<int, int> prr[5];
    for (int i = 1; i <= 4; i++) {
        int num;
        cout << "? " << i << " " << i + 1 << endl << flush;
        cin >> num;
        for (int j = 0; j < 5; j++) {
            for (int k = j + 1; k < 6; k++) {
                if (arr[j] * arr[k] == num) {
                    prr[i].first = arr[j];
                    prr[i].second = arr[k];
                }
            }
        }
    }
    if (prr[1].first == prr[2].first) {
        swap(prr[1].first, prr[1].second);
    } else if (prr[1].first == prr[2].second){
        swap(prr[1].first, prr[1].second);
        swap(prr[2].first, prr[2].second);
    } else if (prr[1].second == prr[2].second) {
        swap(prr[2].first, prr[2].second);
    }
    for (int i = 2; i <= 4; i++) {
        if (prr[i].first == prr[i - 1].first) {
            swap(prr[i].first, prr[i].second);
        }
    }
    int answer[6] = {prr[1].first};
    for (int i = 1; i <= 4; i++) {
        answer[i] = prr[i].second;
    }
    for (int i = 0; i < 6; i++) {
        bool state = true;
        for (int j = 0; j < 5; j++) {
            if (arr[i] == answer[j]) {
                state = false;
                break;
            }
        }
        if (state) {
            answer[5] = arr[i];
            break;
        }
    }
    cout << "!";
    for (int i = 0; i < 6; i++) {
        cout << " " << answer[i];
    }
    cout << endl << flush;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <set>

typedef long long ll;

using namespace std;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int arr[6] = {4, 8, 15, 16, 23, 42};
    pair<int, int> prr[6];
    int index = 1;
    for (int i = 1; i <= 4; i++) {
        int num;
        cout << "? " << i << " " << i + 1 << endl;
        cout << flush;
        cin >> num;
        num = nrr[i-1];
        for (int j = 0; j < 6; j++) {
            for (int k = j; k < 6; k++) {
                if (arr[j] * arr[k] == num) {
                    prr[index].first = arr[j];
                    prr[index].second = arr[k];
                    index++;
                }
            }
        }
    }
    pair<int, int> qrr[6];
    if (index == 6) {
        for (int i = 1; i < 6; i++) {
            qrr[i] = prr[i];
        }
        bool state = true;
        for (int i = 1; i < 6; i++) {
            if (not state) {
                prr[i - 1] = prr[i];
            }
            if (prr[i].first == 8 and prr[i].second == 8) {
                state = false;
            }
        }
        state = true;
        for (int i = 1; i < 6; i++) {
            if (not state) {
                qrr[i - 1] = qrr[i];
            }
            if ((qrr[i].first == 4 and qrr[i].second == 16) or (qrr[i].first == 16 and qrr[i].second == 4)) {
                state = false;
            }
        }
    }
    if (prr[1].first == prr[2].first) {
        swap(prr[1].first, prr[1].second);
    } else if (prr[1].first == prr[2].second){
        swap(prr[1].first, prr[1].second);
        swap(prr[2].first, prr[2].second);
    } else if (prr[1].second == prr[2].second) {
        swap(prr[2].first, prr[2].second);
    }
    for (int i = 2; i <= 4; i++) {
        if (prr[i].first == prr[i - 1].first) {
            swap(prr[i].first, prr[i].second);
        }
    }
    int answer[6] = {prr[1].first};
    for (int i = 1; i <= 4; i++) {
        answer[i] = prr[i].second;
    }
    for (int i = 0; i < 6; i++) {
        bool state = true;
        for (int j = 0; j < 5; j++) {
            if (arr[i] == answer[j]) {
                state = false;
                break;
            }
        }
        if (state) {
            answer[5] = arr[i];
            break;
        }
    }
    int answer2[6];
    if (index == 6) {
        for (int i = 1; i < 5; i++) {
            prr[i] = qrr[i];
        }
        if (prr[1].first == prr[2].first) {
            swap(prr[1].first, prr[1].second);
        } else if (prr[1].first == prr[2].second){
            swap(prr[1].first, prr[1].second);
            swap(prr[2].first, prr[2].second);
        } else if (prr[1].second == prr[2].second) {
            swap(prr[2].first, prr[2].second);
        }
        for (int i = 2; i <= 4; i++) {
            if (prr[i].first == prr[i - 1].first) {
                swap(prr[i].first, prr[i].second);
            }
        }
        answer2[0] = {prr[1].first};
        for (int i = 1; i <= 4; i++) {
            answer2[i] = prr[i].second;
        }
        for (int i = 0; i < 6; i++) {
            bool state = true;
            for (int j = 0; j < 5; j++) {
                if (arr[i] == answer2[j]) {
                    state = false;
                    break;
                }
            }
            if (state) {
                answer2[5] = arr[i];
                break;
            }
        }
    }
    bool state1 = true;
    for (int i = 0; i < 6; i++) {
        bool state = true;
        for (int j = 0; j < 6; j++) {
            if (answer[i] == arr[j]) {
                state = false;
                break;
            }
        }
        if (state) {
            state1 = false;
            break;
        }
    }
    if (state1) {
        cout << "!";
        for (int i = 0; i < 6; i++) {
            cout << " " << answer[i];
        }
        cout << endl << flush;
    }
    else {
        cout << "!";
        for (int i = 0; i < 6; i++) {
            cout << " " << answer2[i];
        }
        cout << endl << flush;
    }
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <set>

typedef long long ll;

using namespace std;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int arr[6] = {4, 8, 15, 16, 23, 42};
    pair<int, int> prr[6];
    int index = 1;
    for (int i = 1; i <= 4; i++) {
        int num;
        cout << "? " << i << " " << i + 1 << endl;
        cout << flush;
        cin >> num;
        for (int j = 0; j < 6; j++) {
            for (int k = j; k < 6; k++) {
                if (arr[j] * arr[k] == num) {
                    prr[index].first = arr[j];
                    prr[index].second = arr[k];
                    index++;
                }
            }
        }
    }
    pair<int, int> qrr[6];
    if (index == 6) {
        for (int i = 1; i < 6; i++) {
            qrr[i] = prr[i];
        }
        bool state = true;
        for (int i = 1; i < 6; i++) {
            if (not state) {
                prr[i - 1] = prr[i];
            }
            if (prr[i].first == 8 and prr[i].second == 8) {
                state = false;
            }
        }
        state = true;
        for (int i = 1; i < 6; i++) {
            if (not state) {
                qrr[i - 1] = qrr[i];
            }
            if ((qrr[i].first == 4 and qrr[i].second == 16) or (qrr[i].first == 16 and qrr[i].second == 4)) {
                state = false;
            }
        }
    }
    if (prr[1].first == prr[2].first) {
        swap(prr[1].first, prr[1].second);
    } else if (prr[1].first == prr[2].second){
        swap(prr[1].first, prr[1].second);
        swap(prr[2].first, prr[2].second);
    } else if (prr[1].second == prr[2].second) {
        swap(prr[2].first, prr[2].second);
    }
    for (int i = 2; i <= 4; i++) {
        if (prr[i].first == prr[i - 1].first) {
            swap(prr[i].first, prr[i].second);
        }
    }
    int answer[6] = {prr[1].first};
    for (int i = 1; i <= 4; i++) {
        answer[i] = prr[i].second;
    }
    for (int i = 0; i < 6; i++) {
        bool state = true;
        for (int j = 0; j < 5; j++) {
            if (arr[i] == answer[j]) {
                state = false;
                break;
            }
        }
        if (state) {
            answer[5] = arr[i];
            break;
        }
    }
    int answer2[6];
    if (index == 6) {
        for (int i = 1; i < 5; i++) {
            prr[i] = qrr[i];
        }
        if (prr[1].first == prr[2].first) {
            swap(prr[1].first, prr[1].second);
        } else if (prr[1].first == prr[2].second){
            swap(prr[1].first, prr[1].second);
            swap(prr[2].first, prr[2].second);
        } else if (prr[1].second == prr[2].second) {
            swap(prr[2].first, prr[2].second);
        }
        for (int i = 2; i <= 4; i++) {
            if (prr[i].first == prr[i - 1].first) {
                swap(prr[i].first, prr[i].second);
            }
        }
        answer2[0] = {prr[1].first};
        for (int i = 1; i <= 4; i++) {
            answer2[i] = prr[i].second;
        }
        for (int i = 0; i < 6; i++) {
            bool state = true;
            for (int j = 0; j < 5; j++) {
                if (arr[i] == answer2[j]) {
                    state = false;
                    break;
                }
            }
            if (state) {
                answer2[5] = arr[i];
                break;
            }
        }
    }
    bool state1 = true;
    for (int i = 0; i < 6; i++) {
        bool state = true;
        for (int j = 0; j < 6; j++) {
            if (answer[i] == arr[j]) {
                state = false;
                break;
            }
        }
        if (state) {
            state1 = false;
            break;
        }
    }
    if (state1) {
        cout << "!";
        for (int i = 0; i < 6; i++) {
            cout << " " << answer[i];
        }
        cout << endl << flush;
    }
    else {
        cout << "!";
        for (int i = 0; i < 6; i++) {
            cout << " " << answer2[i];
        }
        cout << endl << flush;
    }
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <set>

typedef long long ll;

using namespace std;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int arr[6] = {4, 8, 15, 16, 23, 42};
    int answer[6];
    for (int i = 1; i <= 2; i++) {
        int num;
        cout << "? " << i << " " << i << endl << flush;
        cin >> num;
        for (int a : arr) {
            if (a * a == num) {
                answer[i - 1] = a;
            }
        }
    }
    for (int i = 3; i <= 4; i++) {
        int num;
        cout << "? " << i << " " << i + 1 << endl << flush;
        cin >> num;
        for (int j = 0; j < 5; j++) {
            for (int k = j + 1; k < 6; k++) {
                if (arr[j] * arr[k] == num) {
                    answer[i * 2 - 4] = arr[j];
                    answer[i * 2 - 3] = arr[k];
                }
            }
        }
    }
    if (answer[2] == answer[5]) {
        answer[2] = answer[3];
        answer[3] = answer[5];
    } else if (answer[2] == answer[4]) {
        answer[2] = answer[3];
        answer[3] = answer[4];
        answer[4] = answer[5];
    } else if (answer[3] == answer[4]) {
        answer[4] = answer[5];
    }
    for (int a : arr) {
        bool state = true;
        for (int j = 0; j < 5; j++) {
            if (a == answer[j]) {
                state = false;
                break;
            }
        }
        if (state) {
            answer[5] = a;
            break;
        }
    }
    cout << "!";
    for (int a : answer) {
        cout << " " << a;
    }
    cout << endl << flush;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <set>

typedef long long ll;

using namespace std;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int arr[6] = {4, 8, 15, 16, 23, 42};
    pair<int, int> prr[5];
    for (int i = 1; i <= 4; i++) {
        int num;
        cout << "? " << i << " " << i + 1;
        fflush(stdout);
        cin >> num;
        for (int j = 0; j < 6; j++) {
            for (int k = 0; k < 6; k++) {
                if (arr[j] * arr[k] == num) {
                    prr[i].first = j;
                    prr[i].second = k;
                }
            }
        }
    }
    if (prr[1].first == prr[2].first) {
        swap(prr[1].first, prr[1].second);
    } else if (prr[1].first == prr[2].second){
        swap(prr[1].first, prr[1].second);
        swap(prr[2].first, prr[2].second);
    } else if (prr[1].second == prr[2].second) {
        swap(prr[2].first, prr[2].second);
    }
    for (int i = 2; i <= 4; i++) {
        if (prr[i].first == prr[i - 1].first) {
            swap(prr[i].first, prr[i].second);
        }
    }
    int answer[6] = {prr[1].first};
    for (int i = 1; i <= 4; i++) {
        answer[i] = prr[i].second;
    }
    for (int i = 0; i < 6; i++) {
        bool state = true;
        for (int j = 0; j < 5; j++) {
            if (arr[i] == answer[j]) {
                state = false;
                break;
            }
        }
        if (state) {
            answer[5] = arr[i];
            break;
        }
    }
    cout << "!";
    for (int i = 0; i < 6; i++) {
        cout << " " << answer[i];
    }
    exit(0);
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <set>

typedef long long ll;

using namespace std;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int arr[6] = {4, 8, 15, 16, 23, 42};
    pair<int, int> prr[5];
    for (int i = 1; i <= 4; i++) {
        int num;
        cout << "? " << i << " " << i + 1;
        cout << flush;
        cin >> num;
        for (int j = 0; j < 6; j++) {
            for (int k = 0; k < 6; k++) {
                if (arr[j] * arr[k] == num) {
                    prr[i].first = j;
                    prr[i].second = k;
                }
            }
        }
    }
    if (prr[1].first == prr[2].first) {
        swap(prr[1].first, prr[1].second);
    } else if (prr[1].first == prr[2].second){
        swap(prr[1].first, prr[1].second);
        swap(prr[2].first, prr[2].second);
    } else if (prr[1].second == prr[2].second) {
        swap(prr[2].first, prr[2].second);
    }
    for (int i = 2; i <= 4; i++) {
        if (prr[i].first == prr[i - 1].first) {
            swap(prr[i].first, prr[i].second);
        }
    }
    int answer[6] = {prr[1].first};
    for (int i = 1; i <= 4; i++) {
        answer[i] = prr[i].second;
    }
    for (int i = 0; i < 6; i++) {
        bool state = true;
        for (int j = 0; j < 5; j++) {
            if (arr[i] == answer[j]) {
                state = false;
                break;
            }
        }
        if (state) {
            answer[5] = arr[i];
            break;
        }
    }
    cout << "!";
    for (int i = 0; i < 6; i++) {
        cout << " " << answer[i];
    }
    cout << flush;
    exit(0);
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <set>

typedef long long ll;

using namespace std;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int arr[6] = {4, 8, 15, 16, 23, 42};
    pair<int, int> prr[5];
    for (int i = 1; i <= 4; i++) {
        int num;
        cout << "? " << i << " " << i + 1 << endl;
        cout << flush;
        cin >> num;
        for (int j = 0; j < 6; j++) {
            for (int k = j; k < 6; k++) {
                if (arr[j] * arr[k] == num) {
                    prr[i].first = arr[j];
                    prr[i].second = arr[k];
                }
            }
        }
    }
    if (prr[1].first == prr[2].first) {
        swap(prr[1].first, prr[1].second);
    } else if (prr[1].first == prr[2].second){
        swap(prr[1].first, prr[1].second);
        swap(prr[2].first, prr[2].second);
    } else if (prr[1].second == prr[2].second) {
        swap(prr[2].first, prr[2].second);
    }
    for (int i = 2; i <= 4; i++) {
        if (prr[i].first == prr[i - 1].first) {
            swap(prr[i].first, prr[i].second);
        }
    }
    int answer[6] = {prr[1].first};
    for (int i = 1; i <= 4; i++) {
        answer[i] = prr[i].second;
    }
    for (int i = 0; i < 6; i++) {
        bool state = true;
        for (int j = 0; j < 5; j++) {
            if (arr[i] == answer[j]) {
                state = false;
                break;
            }
        }
        if (state) {
            answer[5] = arr[i];
            break;
        }
    }
    cout << "!";
    for (int i = 0; i < 6; i++) {
        cout << " " << answer[i];
    }
    cout << endl << flush;
}


    #include<bits/stdc++.h>
    using namespace std;

    #define ll           long long
    #define pii          pair<ll,ll>
    #define bug(a)       cerr << #a << " : " << a << endl;
    #define FastRead     ios_base::sync_with_stdio(false);cin.tie(NULL);

    const int MAX = 1e6;
    int ss[7] = {4,8,15,16,23,42};
    int main()
    {
        int i = 1 , j = 2 , r;

        vector<int>v;

        int a[7];

        for(;i<=4;i++)
        {
            cout << "? " << 1 << " " << 1 << endl;

            fflush(stdout);

            cin >> r;

            v.push_back(r);
        }

        do
        {
            if(ss[0]*ss[1] == v[0] && ss[1]*ss[2] == v[1] && ss[2]*ss[3] == v[2] && ss[3]*ss[4] == v[3])
              {
                 //cout << ss[0] << ' ' << ss[1] << endl;
                 break;
              }
        }
        while(next_permutation(ss,ss+6));

        cout << "! ";
        for(int i=0;i<6;i++)
            cout << ss[i] << " ";
        cout << endl;
    }


#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<int> vec[500010];
int visit[500010];
map<int  , int > mp;
int main()
{  int a,b,c,d;
int ara[] = {4,8,15,16,23,42};
set<int>st;
 //cin >> a >> b >> c >> d;
 cout << "? 1 1" <<endl;
 fflush(stdout);
 cin >> a ;
 for(int i=0; i<6; i++)
 {
     if(a%ara[i]==0)
        st.insert(ara[i]);
 }
 cout << "? 1 1" <<endl;
 fflush(stdout);
 cin >> a ;
  for(int i=0; i<6; i++)
 {
     if(a%ara[i]==0)
        st.insert(ara[i]);
 }
 cout << "? 1 1" <<endl;
 fflush(stdout);
 cin >> a ;
  for(int i=0; i<6; i++)
 {
     if(a%ara[i]==0)
        st.insert(ara[i]);
 }
 cout << "? 1 1" <<endl;
 fflush(stdout);
 cin >> a ;
 for(int i=0; i<6; i++)
 {
     if(a%ara[i]==0)
        st.insert(ara[i]);
 }
cout << "! ";
for(auto i=st.begin(); i!=st.end(); ++i)
{
    cout << *i << " " ;
}
fflush(stdout);

}


    #include<bits/stdc++.h>
    using namespace std;

    #define ll           long long
    #define pii          pair<ll,ll>
    #define bug(a)       cerr << #a << " : " << a << endl;
    #define FastRead     ios_base::sync_with_stdio(false);cin.tie(NULL);

    const int MAX = 1e6;
    int ss[7] = {4,8,15,16,23,42};
    int main()
    {
        int i = 1 , j = 3 , r;

        vector<int>v;

        int a[7];

        for(;i<=4;i++,j++)
        {
            cout << "? " << i << " " << i+2 << endl;

            fflush(stdout);

            cin >> r;

            v.push_back(r);
        }

        do
        {
            if(ss[0]*ss[1] == v[0] && ss[1]*ss[2] == v[1] && ss[2]*ss[3] == v[2] && ss[3]*ss[4] == v[3])
              {
                 //cout << ss[0] << ' ' << ss[1] << endl;
                 break;
              }
        }
        while(next_permutation(ss,ss+6));

        cout << "! ";
        for(int i=0;i<6;i++)
            cout << ss[i] << " ";
        cout << endl;
    }


#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<int> vec[500010];
int visit[500010];
map<int  , int > mp;
int main()
{  int a,b,c,d;
 //cin >> a >> b >> c >> d;
 cin >> a ;
 cout << "? 1 1" <<endl;
  cin >> b;
 cout << "? 1 1" <<endl;
 cin >> c ;
 cout << "? 1 1" <<endl;
  cin >> d;
 cout << "? 1 1" <<endl;
 cout << "! 4 8 15 16 23 42" << endl;

 fflush(stdout);
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<int> vec[500010];
int visit[500010];
map<int  , int > mp;
int main()
{  int a,b,c,d;
int ara[] = {4,8,15,16,23,42};
set<int>st;
 //cin >> a >> b >> c >> d;
 cout << "? 1 1" <<endl;
 fflush(stdout);
 cin >> a ;
 for(int i=0; i<6; i++)
 {
     if(a%ara[i]==0)
        st.insert(ara[i]);
 }
 cout << "? 1 1" <<endl;
 fflush(stdout);
 cin >> a ;
  for(int i=0; i<6; i++)
 {
     if(a%ara[i]==0)
        st.insert(ara[i]);
 }
 cout << "? 1 1" <<endl;
 fflush(stdout);
 cin >> a ;
  for(int i=0; i<6; i++)
 {
     if(a%ara[i]==0)
        st.insert(ara[i]);
 }
 cout << "? 1 1" <<endl;
 fflush(stdout);
 cin >> a ;
 for(int i=0; i<6; i++)
 {
     if(a%ara[i]==0)
        st.insert(ara[i]);
 }
cout << "! ";
for(auto i=st.begin(); i!=st.end(); ++i)
{
    cout << *i << " " ;
}
cout << endl;
fflush(stdout);

}


    #include<bits/stdc++.h>
    using namespace std;

    #define ll           long long
    #define pii          pair<ll,ll>
    #define bug(a)       cerr << #a << " : " << a << endl;
    #define FastRead     ios_base::sync_with_stdio(false);cin.tie(NULL);

    const int MAX = 1e6;
    int ss[7] = {4,8,15,16,23,42};
    int main()
    {
        int i = 1 , j = 2 , r;

        vector<int>v;

        int a[7];

        for(;i<=4;i++,j++)
        {
            cout << "? " << i << " " << j << endl;

            fflush(stdout);

            cin >> r;

            v.push_back(r);
        }

        do
        {
            if(ss[0]*ss[1] == v[0] && ss[1]*ss[2] == v[1] && ss[2]*ss[3] == v[2] && ss[3]*ss[4] == v[3])
              {
                 //cout << ss[0] << ' ' << ss[1] << endl;
                 break;
              }
        }
        while(next_permutation(ss,ss+6));

        cout << "! ";
        for(int i=0;i<6;i++)
            cout << ss[i] << " ";
        cout << endl;
    }


#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<int> vec[500010];
int visit[500010];
map<int  , int > mp;
int main()
{  int a,b,c,d;
int ara[] = {4,8,15,16,23,42};
set<int>st;
 //cin >> a >> b >> c >> d;
 cout << "? 1 1" <<endl;
 fflush(stdout);
 cin >> a ;
 for(int i=0; i<6; i++)
 {
     if(a%ara[i]==0)
        st.insert(ara[i]);
 }
 cout << "? 1 1" <<endl;
 fflush(stdout);
 cin >> a ;
  for(int i=0; i<6; i++)
 {
     if(a%ara[i]==0)
        st.insert(ara[i]);
 }
 cout << "? 1 1" <<endl;
 fflush(stdout);
 cin >> a ;
  for(int i=0; i<6; i++)
 {
     if(a%ara[i]==0)
        st.insert(ara[i]);
 }
 cout << "? 1 1" <<endl;
 fflush(stdout);
 cin >> a ;
 for(int i=0; i<6; i++)
 {
     if(a%ara[i]==0)
        st.insert(ara[i]);
 }
cout << "!";
for(auto i=st.begin(); i!=st.end(); ++i)
{
    cout<< " "  << *i ;
}
cout << endl;
fflush(stdout);

}


    #include<bits/stdc++.h>
    using namespace std;

    #define ll           long long
    #define pii          pair<ll,ll>
    #define bug(a)       cerr << #a << " : " << a << endl;
    #define FastRead     ios_base::sync_with_stdio(false);cin.tie(NULL);

    const int MAX = 1e6;
    int ss[7] = {4,8,15,16,23,42};
    int main()
    {
        int i = 1 , j = 3 , r;

        vector<int>v;

        int a[7];

        for(;i<=4;i++,j++)
        {
            cout << "? " << i << " " << i+1 << endl;

            fflush(stdout);

            cin >> r;

            v.push_back(r);
        }

        do
        {
            if(ss[0]*ss[1] == v[0] && ss[1]*ss[2] == v[1] && ss[2]*ss[3] == v[2] && ss[3]*ss[4] == v[3])
              {
                 //cout << ss[0] << ' ' << ss[1] << endl;
                 break;
              }
        }
        while(next_permutation(ss,ss+6));

        cout << "! ";
        for(int i=0;i<6;i++)
            cout << ss[i] << " ";
        cout << endl;
    }


    #include<bits/stdc++.h>
    using namespace std;

    #define ll           long long
    #define pii          pair<ll,ll>
    #define bug(a)       cerr << #a << " : " << a << endl;
    #define FastRead     ios_base::sync_with_stdio(false);cin.tie(NULL);

    const int MAX = 1e6;
    int ss[7] = {4,8,15,16,23,42};
    int main()
    {
        int i = 1 , j = 2 , r;

        vector<int>v;

        int a[7];

        for(;i<=4;i++)
        {
            cout << "? " << 1 << " " << 1 << endl;

            fflush(stdout);

            cin >> r;

            v.push_back(r);
        }

        do
        {
            if(ss[0]*ss[1] == v[0] && ss[1]*ss[2] == v[1] && ss[2]*ss[3] == v[2] && ss[3]*ss[4] == v[3])
              {
                 cout << ss[0] << ' ' << ss[1] << endl;
                 break;
              }
        }
        while(next_permutation(ss,ss+6));

        cout << "! ";
        for(int i=0;i<6;i++)
            cout << ss[i] << " ";
        cout << endl;
    }


    #include<bits/stdc++.h>
    using namespace std;

    #define ll           long long
    #define pii          pair<ll,ll>
    #define bug(a)       cerr << #a << " : " << a << endl;
    #define FastRead     ios_base::sync_with_stdio(false);cin.tie(NULL);

    const int MAX = 1e6;
    int ss[7] = {4,8,15,16,23,42};
    int main()
    {
        int i = 1 , j = 3 , r;

        vector<int>v;

        int a[7];

        for(;i<=4;i++,j++)
        {
            cout << "? " << i << " " << j << endl;

            fflush(stdout);

            cin >> r;

            v.push_back(r);
        }

        do
        {
            if(ss[0]*ss[1] == v[0] && ss[1]*ss[2] == v[1] && ss[2]*ss[3] == v[2] && ss[3]*ss[4] == v[3])
              {
                 //cout << ss[0] << ' ' << ss[1] << endl;
                 break;
              }
        }
        while(next_permutation(ss,ss+6));

        cout << "! ";
        for(int i=0;i<6;i++)
            cout << ss[i] << " ";
        cout << endl;
    }


    #include<bits/stdc++.h>
    using namespace std;

    #define ll           long long
    #define pii          pair<ll,ll>
    #define bug(a)       cerr << #a << " : " << a << endl;
    #define FastRead     ios_base::sync_with_stdio(false);cin.tie(NULL);

    const int MAX = 1e6;
    int ss[7] = {4,8,15,16,23,42};
    int main()
    {
        int i = 1 , j = 2 , r;

        vector<int>v;

        int a[7];

        for(;i<=4;i++,j+=2)
        {
            cout << "? " << i << " " << j << endl;

            fflush(stdout);

            cin >> r;

            v.push_back(r);
        }

        do
        {
            if(ss[0]*ss[1] == v[0] && ss[1]*ss[2] == v[1] && ss[2]*ss[3] == v[2] && ss[3]*ss[4] == v[3])
              {
                 //cout << ss[0] << ' ' << ss[1] << endl;
                 break;
              }
        }
        while(next_permutation(ss,ss+6));

        cout << "! ";
        for(int i=0;i<6;i++)
            cout << ss[i] << " ";
        cout << endl;
    }


#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<int> vec[500010];
int visit[500010];
map<int  , int > mp;
int main()
{  int a,b,c,d;
 //cin >> a >> b >> c >> d;
 cout << "? 1 1" <<endl;
 fflush(stdout);
 cin >> a ;
 cout << "? 1 1" <<endl;
 fflush(stdout);
 cin >> a ;
 cout << "? 1 1" <<endl;
 fflush(stdout);
 cin >> a ;
 cout << "? 1 1" <<endl;
 fflush(stdout);
 cin >> a ;

 cout << "! 4 8 15 16 23 42" << endl;
fflush(stdout);

}


#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
	ll a , b,c,d;
	cout<<"? "<<1<<" "<<2<<endl;
	fflush(stdout);
	cin>>a;
	cout<<"? "<<2<<" "<<3<<endl;
	fflush(stdout);
	cin>>b;
	cout<<"? "<<4<<" "<<5<<endl;
	fflush(stdout);
	cin>>c;
	cout<<"? "<<5<<" "<<6<<endl;
	fflush(stdout);
	cin>>d;
	map <ll,ll> ada;
	ada[4] = 1;
	ada[8] = 1;
	ada[16] = 1;
	ada[23] = 1;
	ada[42] = 1;
	ada[15] = 1;
	map<ll,ll> :: iterator it;
	ll k , l;
	for(it = ada.begin() ; it != ada.end() ; ++it)
	{
			ll ta = a/it->first;
			ll tk = it->first;
			ll tb = b/it->first;
		if(a%it->first == 0 && b %it->first == 0 && ada.count(ta)>0 && ada.count(tk)>0 && ada.count(tb) > 0)
		{
			a = a/it->first;
			k = it->first;
			b = b/it->first;
			ada[a] = 0;
			ada[k] = 0;
			ada[b] = 0;
			break;
		}
	}
	for(it = ada.begin() ; it != ada.end() ; ++it)
	{
		ll	tc = c/it->first;
		ll	tl = it->first;
		ll	td = d/it->first;
		if(c%it->first == 0 && d %it->first == 0 && ada.count(tc)>0 && ada.count(tl) >0&& ada.count(td)>0)
		{
			c = c/it->first;
			l = it->first;
			d = d/it->first;
			break;
		}
	}

	cout<<"! "<<a<<" "<<k<<" "<<b<<" "<<c<<" "<<l<<" "<<d<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
	ll a , b,c,d;
	cout<<"? "<<1<<" "<<2<<endl;
	fflush(stdout);
	cin>>a;
	cout<<"? "<<2<<" "<<3<<endl;
	fflush(stdout);
	cin>>b;
	cout<<"? "<<4<<" "<<5<<endl;
	fflush(stdout);
	cin>>c;
	cout<<"? "<<5<<" "<<6<<endl;
	fflush(stdout);
	cin>>d;
	map <ll,ll> ada;
	ada[4] = 1;
	ada[8] = 1;
	ada[16] = 1;
	ada[23] = 1;
	ada[42] = 1;
	ada[15] = 1;
	map<ll,ll> :: iterator it;
	ll k , l;
	for(it = ada.begin() ; it != ada.end() ; ++it)
	{
			ll ta = a/it->first;
			if(a%it->first !=0) ta = -1;
			ll tk = it->first;

			ll tb = b/it->first;
			if(b%it->first != 0) tb = -1;
		if(a%it->first == 0 && b %it->first == 0 && ada.count(ta)>0 && ada.count(tk)>0 && ada.count(tb) > 0)
		{
			a = a/it->first;
			k = it->first;
			b = b/it->first;
			ada[a] = 0;
			ada[k] = 0;
			ada[b] = 0;
			break;
		}
	}
	for(it = ada.begin() ; it != ada.end() ; ++it)
	{
		ll	tc = c/it->first;
		if(c%it->first !=0) tc = -1;
		ll	tl = it->first;
		ll	td = d/it->first;
		if(d%it->first != 0) td = -1;
		if(c%it->first == 0 && d %it->first == 0 && ada.count(tc)>0 && ada.count(tl) >0&& ada.count(td)>0)
		{
			c = c/it->first;
			l = it->first;
			d = d/it->first;

			break;
		}
	}
//	if(ada[a] == 0 || ada[k] == 0 || ada[b] == 0 || ada[l] == 0 || ada[c] == 0 || ada[d] == 0) cout<<5/0<<endl;
	cout<<"! "<<a<<" "<<k<<" "<<b<<" "<<c<<" "<<l<<" "<<d<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
	ll a , b,c,d;
	cout<<"? "<<1<<" "<<2<<endl;
	fflush(stdout);
	cin>>a;
	cout<<"? "<<2<<" "<<3<<endl;
	fflush(stdout);
	cin>>b;
	cout<<"? "<<4<<" "<<5<<endl;
	fflush(stdout);
	cin>>c;
	cout<<"? "<<5<<" "<<6<<endl;
	fflush(stdout);
	cin>>d;
	map <ll,ll> ada;
	ada[4] = 1;
	ada[8] = 1;
	ada[16] = 1;
	ada[23] = 1;
	ada[42] = 1;
	ada[15] = 1;
	map<ll,ll> :: iterator it;
	ll k , l;
	for(it = ada.begin() ; it != ada.end() ; ++it)
	{
			ll ta = a/it->first;
			ll tk = it->first;
			ll tb = b/it->first;
		if(a%it->first == 0 && b %it->first == 0 && ada.count(ta)>0 && ada.count(tk)>0 && ada.count(tb) > 0)
		{
			a = a/it->first;
			k = it->first;
			b = b/it->first;
			ada[a] = 0;
			ada[k] = 0;
			ada[b] = 0;
			break;
		}
	}
	for(it = ada.begin() ; it != ada.end() ; ++it)
	{
		ll	tc = c/it->first;
		ll	tl = it->first;
		ll	td = d/it->first;
		if(c%it->first == 0 && d %it->first == 0 && ada.count(tc)>0 && ada.count(tl) >0&& ada.count(td)>0)
		{
			c = c/it->first;
			l = it->first;
			d = d/it->first;
			ada[a] = 1;
			ada[b] = 1;
			ada[k] = 1;
			break;
		}
	}
	if(ada[a] == 0 || ada[k] == 0 || ada[b] == 0 || ada[l] == 0 || ada[c] == 0 || ada[d] == 0) cout<<5/0<<endl;
	cout<<"! "<<a<<" "<<k<<" "<<b<<" "<<c<<" "<<l<<" "<<d<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
	ll a , b,c,d;
	cout<<"? "<<1<<" "<<2<<endl;
	fflush(stdout);
	cin>>a;
	cout<<"? "<<2<<" "<<3<<endl;
	fflush(stdout);
	cin>>b;
	cout<<"? "<<4<<" "<<5<<endl;
	fflush(stdout);
	cin>>c;
	cout<<"? "<<5<<" "<<6<<endl;
	fflush(stdout);
	cin>>d;
	map <ll,ll> ada;
	ada[4] = 1;
	ada[8] = 1;
	ada[16] = 1;
	ada[23] = 1;
	ada[42] = 1;
	ada[15] = 1;
	ll arr[] = {4,8,16,23,42,15};
	map<ll,ll> :: iterator it;
	ll k , l;
	for(int i = 0 ; i < 6;  i++)
	{
		for(int j =i+1 ; j < 6; j++)
		{
			ll ta = a/arr[i];
			ll tb = b/arr[i];
			ll tc = c/arr[j];
			ll td = d/arr[j];
			vector<ll> z;
			z.push_back(ta);
			z.push_back(tb);
			z.push_back(tc);z.push_back(td);
			bool valid = 1;
			for(int k = 0 ; k < 4; k++)
			{
				for(int l = k+1 ; l < 4; l++)
				{
					if(z[k] == z[l])
					{
						valid =0 ;
						break;
					}
				}
			}
			if(a%arr[i] == 0 && b%arr[i] == 0 && ada.count(a/arr[i]) > 0 && ada.count(b/arr[i]) > 0 &&
			c%arr[j] == 0 && d%arr[j] == 0 && ada.count(c/arr[j]) > 0 && ada.count(d/arr[j]) > 0
			&& valid)
			{
				cout<<"! "<<a/arr[i]<<" "<<arr[i] << " "<<b/arr[i]<<" "<<c/arr[j]<<" "<<arr[j]<<" "<<d/arr[j]<<endl;
				break;
			}
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
	ll a , b,c,d;
	cout<<"? "<<1<<" "<<2<<endl;
	fflush(stdout);
	cin>>a;
	cout<<"? "<<2<<" "<<3<<endl;
	fflush(stdout);
	cin>>b;
	cout<<"? "<<4<<" "<<5<<endl;
	fflush(stdout);
	cin>>c;
	cout<<"? "<<5<<" "<<6<<endl;
	fflush(stdout);
	cin>>d;
	map <ll,ll> ada;
	ada[4] = 1;
	ada[8] = 1;
	ada[16] = 1;
	ada[23] = 1;
	ada[42] = 1;
	ada[15] = 1;
	map<ll,ll> :: iterator it;
	ll k , l;
	k = __gcd(a,b);
	for(it = ada.begin() ; it != ada.end() ; ++it)
	{
		if(ada[k]) break;
		if(k%it->first == 0)
		{
			k =  it->first;
		}
	}
	a = a/k;
	b = b/k;
	l = __gcd(c,d);
	for(it = ada.begin() ; it != ada.end() ; ++it)
	{
		if(ada[l]) break;
		if(l%it->first == 0)
		{
			l =  it->first;
		}
	}
//	cout<<c<<" "<<d<<endl;
//	cout<<l<<endl;
	c = c/l;
	d = d/l;
	cout<<"! "<<a<<" "<<k<<" "<<b<<" "<<c<<" "<<l<<" "<<d<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
	ll a , b,c,d;
	cout<<"? "<<1<<" "<<2<<endl;
	fflush(stdout);
	cin>>a;
	cout<<"? "<<2<<" "<<3<<endl;
	fflush(stdout);
	cin>>b;
	cout<<"? "<<4<<" "<<5<<endl;
	fflush(stdout);
	cin>>c;
	cout<<"? "<<5<<" "<<6<<endl;
	fflush(stdout);
	cin>>d;
	map <ll,ll> ada;
	ada[4] = 1;
	ada[8] = 1;
	ada[16] = 1;
	ada[23] = 1;
	ada[42] = 1;
	ada[15] = 1;
	map<ll,ll> :: iterator it;
	ll k , l;
	k = __gcd(a,b);
	for(it = ada.begin() ; it != ada.end() ; ++it)
	{
		if(ada[k]) break;
		if(k%it->first == 0)
		{
			k =  it->first;
		}
	}
	a = a/k;
	b = b/k;
	l = __gcd(c,d);
	for(it = ada.begin() ; it != ada.end() ; ++it)
	{
		if(ada[l]) break;
		if(l%it->first == 0)
		{
			l =  it->first;
		}
	}
	cout<<c<<" "<<d<<endl;
	cout<<l<<endl;
	c = c/l;
	d = d/l;
	cout<<"! "<<a<<" "<<k<<" "<<b<<" "<<c<<" "<<l<<" "<<d<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
	ll a , b,c,d;
	cout<<"? "<<1<<" "<<2<<endl;
	fflush(stdout);
	cin>>a;
	cout<<"? "<<2<<" "<<3<<endl;
	fflush(stdout);
	cin>>b;
	cout<<"? "<<4<<" "<<5<<endl;
	fflush(stdout);
	cin>>c;
	cout<<"? "<<5<<" "<<6<<endl;
	fflush(stdout);
	cin>>d;
	map <ll,ll> ada;
	ada[4] = 1;
	ada[8] = 1;
	ada[16] = 1;
	ada[23] = 1;
	ada[42] = 1;
	ada[15] = 1;
	map<ll,ll> :: iterator it;
	ll k , l;
	for(it = ada.begin() ; it != ada.end() ; ++it)
	{
			ll ta = a/it->first;
			ll tk = it->first;
			ll tb = b/it->first;
		if(a%it->first == 0 && b %it->first == 0 && ada[ta] && ada[tk] && ada[tb])
		{
			a = a/it->first;
			k = it->first;
			b = b/it->first;

			break;
		}
	}
	for(it = ada.begin() ; it != ada.end() ; ++it)
	{
		ll	tc = c/it->first;
		ll	tl = it->first;
		ll	td = d/it->first;
		if(c%it->first == 0 && d %it->first == 0 && ada[tc] && ada[tl] && ada[td])
		{
			c = c/it->first;
			l = it->first;
			d = d/it->first;
			break;
		}
	}

	cout<<"! "<<a<<" "<<k<<" "<<b<<" "<<c<<" "<<l<<" "<<d<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
	ll a , b,c,d;
	cout<<"? "<<1<<" "<<2<<endl;
	fflush(stdout);
	cin>>a;
	cout<<"? "<<2<<" "<<3<<endl;
	fflush(stdout);
	cin>>b;
	cout<<"? "<<4<<" "<<5<<endl;
	fflush(stdout);
	cin>>c;
	cout<<"? "<<5<<" "<<6<<endl;
	fflush(stdout);
	cin>>d;
	map <ll,ll> ada;
	ada[4] = 1;
	ada[8] = 1;
	ada[16] = 1;
	ada[23] = 1;
	ada[42] = 1;
	ada[15] = 1;
	ll arr[] = {4,8,16,23,42,15};
	map<ll,ll> :: iterator it;
	ll k , l;
	for(int i = 0 ; i < 6;  i++)
	{
		for(int j =i+1 ; j < 6; j++)
		{
			if(a%arr[i] == 0 && b%arr[i] == 0 && ada.count(a/arr[i]) > 0 && ada.count(b/arr[i]) > 0 &&
			c%arr[j] == 0 && d%arr[j] == 0 && ada.count(c/arr[j]) > 0 && ada.count(d/arr[j]) > 0)
			{
				cout<<"! "<<a/arr[i]<<" "<<arr[i] << " "<<b/arr[i]<<" "<<c/arr[j]<<" "<<arr[j]<<" "<<d/arr[j]<<endl;
				break;
			}
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
	ll a , b,c,d;
	cout<<"? "<<1<<" "<<2<<endl;
	fflush(stdout);
	cin>>a;
	cout<<"? "<<2<<" "<<3<<endl;
	fflush(stdout);
	cin>>b;
	cout<<"? "<<4<<" "<<5<<endl;
	fflush(stdout);
	cin>>c;
	cout<<"? "<<5<<" "<<6<<endl;
	fflush(stdout);
	cin>>d;
	map <ll,ll> ada;
	ada[4] = 1;
	ada[8] = 1;
	ada[16] = 1;
	ada[23] = 1;
	ada[42] = 1;
	ada[15] = 1;
	map<ll,ll> :: iterator it;
	ll k , l;
	for(it = ada.begin() ; it != ada.end() ; ++it)
	{
			ll ta = a/it->first;
			ll tk = it->first;
			ll tb = b/it->first;
		if(a%it->first == 0 && b %it->first == 0 && ada.count(ta)>0 && ada.count(tk)>0 && ada.count(tb) > 0)
		{
			a = a/it->first;
			k = it->first;
			b = b/it->first;
			ada[a] = 0;
			ada[k] = 0;
			ada[b] = 0;
			break;
		}
	}
	for(it = ada.begin() ; it != ada.end() ; ++it)
	{
		ll	tc = c/it->first;
		ll	tl = it->first;
		ll	td = d/it->first;
		if(c%it->first == 0 && d %it->first == 0 && ada.count(tc)>0 && ada.count(tl) >0&& ada.count(td)>0)
		{
			c = c/it->first;
			l = it->first;
			d = d/it->first;
			break;
		}
	}
	if(ada[a] == 0 || ada[k] == 0 || ada[b] == 0 || ada[l] == 0 || ada[c] == 0 || ada[d] == 0) cout<<5/0<<endl;
	cout<<"! "<<a<<" "<<k<<" "<<b<<" "<<c<<" "<<l<<" "<<d<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
	ll a , b,c,d;
	cout<<"? "<<1<<" "<<2<<endl;
	fflush(stdout);
	cin>>a;
	cout<<"? "<<2<<" "<<3<<endl;
	fflush(stdout);
	cin>>b;
	cout<<"? "<<4<<" "<<5<<endl;
	fflush(stdout);
	cin>>c;
	cout<<"? "<<5<<" "<<6<<endl;
	fflush(stdout);
	cin>>d;
	map <ll,ll> ada;
	ada[4] = 1;
	ada[8] = 1;
	ada[16] = 1;
	ada[23] = 1;
	ada[42] = 1;
	ada[15] = 1;
	map<ll,ll> :: iterator it;
	ll k , l;
	for(it = ada.begin() ; it != ada.end() ; ++it)
	{
			ll ta = a/it->first;
//			if(a%it->first !=0) continue;
			ll tk = it->first;

			ll tb = b/it->first;
//			if(b%it->first != 0) tb = -1;
		if(a%it->first == 0 && b %it->first == 0 && ada.count(ta)>0 && ada.count(tk)>0 && ada.count(tb) > 0 && ta != tb && tk != ta && tk != tb)
		{
			a = a/it->first;
			k = it->first;
			b = b/it->first;
			ada.erase(a);
			ada.erase(k);
			ada.erase(b);
			break;
		}
	}
//	if(ada.size() == 6) cout<<5/0<<endl;
	for(it = ada.begin() ; it != ada.end() ; ++it)
	{
		ll	tc = c/it->first;
//		if(c%it->first !=0) continue;
		ll	tl = it->first;
		ll	td = d/it->first;
//		if(d%it->first != 0) td = -1;
		if(c%it->first == 0 && d %it->first == 0 && ada.count(tc)>0 && ada.count(tl) >0&& ada.count(td)>0 && tl != tc && tl != td && tc != td)
		{
			c = c/it->first;
			l = it->first;
			d = d/it->first;

			break;
		}
	}
//	if(ada[a] == 0 || ada[k] == 0 || ada[b] == 0 || ada[l] == 0 || ada[c] == 0 || ada[d] == 0) cout<<5/0<<endl;
	cout<<"! "<<a<<" "<<k<<" "<<b<<" "<<c<<" "<<l<<" "<<d<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
	ll a , b,c,d;
	cout<<"? "<<1<<" "<<2<<endl;
	fflush(stdout);
	cin>>a;
	cout<<"? "<<2<<" "<<3<<endl;
	fflush(stdout);
	cin>>b;
	cout<<"? "<<4<<" "<<5<<endl;
	fflush(stdout);
	cin>>c;
	cout<<"? "<<5<<" "<<6<<endl;
	fflush(stdout);
	cin>>d;

	ll k , l;
	k = __gcd(a,b);
	a = a/k;
	b = b/k;
	l = __gcd(c,d);
	c = c/l;
	d = d/l;
	cout<<"! "<<a<<" "<<k<<" "<<b<<" "<<c<<" "<<l<<" "<<d<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
	ll a , b,c,d;
	cout<<"? "<<1<<" "<<2<<endl;
	fflush(stdout);
	cin>>a;
	cout<<"? "<<2<<" "<<3<<endl;
	fflush(stdout);
	cin>>b;
	cout<<"? "<<4<<" "<<5<<endl;
	fflush(stdout);
	cin>>c;
	cout<<"? "<<5<<" "<<6<<endl;
	fflush(stdout);
	cin>>d;

	ll k , l;
	k = __gcd(a,b);
	a = a/k;
	b = b/k;
	l = __gcd(c,d);
	c = c/l;
	d = d/l;
	cout<<"!"<<a<<" "<<k<<" "<<b<<" "<<c<<" "<<l<<" "<<d<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
	ll a , b,c,d;
	cout<<"? "<<1<<" "<<2<<endl;
	fflush(stdout);
	cin>>a;
	cout<<"? "<<2<<" "<<3<<endl;
	fflush(stdout);
	cin>>b;
	cout<<"? "<<4<<" "<<5<<endl;
	fflush(stdout);
	cin>>c;
	cout<<"? "<<5<<" "<<6<<endl;
	fflush(stdout);
	cin>>d;
	map <ll,ll> ada;
	ada[4] = 1;
	ada[8] = 1;
	ada[16] = 1;
	ada[23] = 1;
	ada[42] = 1;
	ada[15] = 1;
	map<ll,ll> :: iterator it;
	ll k , l;
	for(it = ada.begin() ; it != ada.end() ; ++it)
	{
			ll ta = a/it->first;
//			if(a%it->first !=0) continue;
			ll tk = it->first;

			ll tb = b/it->first;
//			if(b%it->first != 0) tb = -1;
		if(a%it->first == 0 && b %it->first == 0 && ada.count(ta)>0 && ada.count(tk)>0 && ada.count(tb) > 0)
		{
			a = a/it->first;
			k = it->first;
			b = b/it->first;
			ada.erase(a);
			ada.erase(k);
			ada.erase(b);
			break;
		}
	}
	if(ada.size() > 3) cout<<5/0<<endl;
	for(it = ada.begin() ; it != ada.end() ; ++it)
	{
		ll	tc = c/it->first;
//		if(c%it->first !=0) continue;
		ll	tl = it->first;
		ll	td = d/it->first;
//		if(d%it->first != 0) td = -1;
		if(c%it->first == 0 && d %it->first == 0 && ada.count(tc)>0 && ada.count(tl) >0&& ada.count(td)>0)
		{
			c = c/it->first;
			l = it->first;
			d = d/it->first;

			break;
		}
	}
//	if(ada[a] == 0 || ada[k] == 0 || ada[b] == 0 || ada[l] == 0 || ada[c] == 0 || ada[d] == 0) cout<<5/0<<endl;
	cout<<"! "<<a<<" "<<k<<" "<<b<<" "<<c<<" "<<l<<" "<<d<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
	ll a , b,c,d;
	cout<<"? "<<1<<" "<<2<<endl;
	fflush(stdout);
	cin>>a;
	cout<<"? "<<2<<" "<<3<<endl;
	fflush(stdout);
	cin>>b;
	cout<<"? "<<4<<" "<<5<<endl;
	fflush(stdout);
	cin>>c;
	cout<<"? "<<5<<" "<<6<<endl;
	fflush(stdout);
	cin>>d;
	map <ll,ll> ada;
	ada[4] = 1;
	ada[8] = 1;
	ada[16] = 1;
	ada[23] = 1;
	ada[42] = 1;
	ada[15] = 1;
	map<ll,ll> :: iterator it;
	ll k , l;
	for(it = ada.begin() ; it != ada.end() ; ++it)
	{
			ll ta = a/it->first;
//			if(a%it->first !=0) continue;
			ll tk = it->first;

			ll tb = b/it->first;
//			if(b%it->first != 0) tb = -1;
		if(a%it->first == 0 && b %it->first == 0 && ada.count(ta)>0 && ada.count(tk)>0 && ada.count(tb) > 0)
		{
			a = a/it->first;
			k = it->first;
			b = b/it->first;
			ada.erase(a);
			ada.erase(k);
			ada.erase(b);
			break;
		}
	}
	for(it = ada.begin() ; it != ada.end() ; ++it)
	{
		ll	tc = c/it->first;
//		if(c%it->first !=0) continue;
		ll	tl = it->first;
		ll	td = d/it->first;
//		if(d%it->first != 0) td = -1;
		if(c%it->first == 0 && d %it->first == 0 && ada.count(tc)>0 && ada.count(tl) >0&& ada.count(td)>0)
		{
			c = c/it->first;
			l = it->first;
			d = d/it->first;

			break;
		}
	}
//	if(ada[a] == 0 || ada[k] == 0 || ada[b] == 0 || ada[l] == 0 || ada[c] == 0 || ada[d] == 0) cout<<5/0<<endl;
	cout<<"! "<<a<<" "<<k<<" "<<b<<" "<<c<<" "<<l<<" "<<d<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
	ll a , b,c,d;
	cout<<"? "<<1<<" "<<2<<endl;
	fflush(stdout);
	cin>>a;
	cout<<"? "<<2<<" "<<3<<endl;
	fflush(stdout);
	cin>>b;
	cout<<"? "<<4<<" "<<5<<endl;
	fflush(stdout);
	cin>>c;
	cout<<"? "<<5<<" "<<6<<endl;
	fflush(stdout);
	cin>>d;
	map <ll,ll> ada;
	ada[4] = 1;
	ada[8] = 1;
	ada[16] = 1;
	ada[23] = 1;
	ada[42] = 1;
	ada[15] = 1;
	map<ll,ll> :: iterator it;
	ll k , l;
	for(it = ada.begin() ; it != ada.end() ; ++it)
	{
			ll ta = a/it->first;
			ll tk = it->first;
			ll tb = b/it->first;
		if(a%it->first == 0 && b %it->first == 0 && ada.count(ta) && ada.count(tk) && ada.count(tb))
		{
			a = a/it->first;
			k = it->first;
			b = b/it->first;
			ada[a] = 0;
			ada[k] = 0;
			ada[b] = 0;
			break;
		}
	}
	for(it = ada.begin() ; it != ada.end() ; ++it)
	{
		ll	tc = c/it->first;
		ll	tl = it->first;
		ll	td = d/it->first;
		if(c%it->first == 0 && d %it->first == 0 && ada.count(tc) && ada.count(tl) && ada.count(td))
		{
			c = c/it->first;
			l = it->first;
			d = d/it->first;
			break;
		}
	}

	cout<<"! "<<a<<" "<<k<<" "<<b<<" "<<c<<" "<<l<<" "<<d<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
	ll a , b,c,d;
	cout<<"? "<<1<<" "<<2<<endl;
	fflush(stdout);
	cin>>a;
	cout<<"? "<<2<<" "<<3<<endl;
	fflush(stdout);
	cin>>b;
	cout<<"? "<<4<<" "<<5<<endl;
	fflush(stdout);
	cin>>c;
	cout<<"? "<<5<<" "<<6<<endl;
	fflush(stdout);
	cin>>d;
	map <ll,ll> ada;
	ada[4] = 1;
	ada[8] = 1;
	ada[16] = 1;
	ada[23] = 1;
	ada[42] = 1;
	ada[15] = 1;
	map<ll,ll> :: iterator it;
	ll k , l;
	for(it = ada.begin() ; it != ada.end() ; ++it)
	{
			ll ta = a/it->first;
//			if(a%it->first !=0) continue;
			ll tk = it->first;

			ll tb = b/it->first;
//			if(b%it->first != 0) tb = -1;
		if(a%it->first == 0 && b %it->first == 0 && ada.count(ta)>0 && ada.count(tk)>0 && ada.count(tb) > 0)
		{
			a = a/it->first;
			k = it->first;
			b = b/it->first;
			ada[a] = 0;
			ada[k] = 0;
			ada[b] = 0;
			break;
		}
	}
	for(it = ada.begin() ; it != ada.end() ; ++it)
	{
		ll	tc = c/it->first;
//		if(c%it->first !=0) continue;
		ll	tl = it->first;
		ll	td = d/it->first;
//		if(d%it->first != 0) td = -1;
		if(c%it->first == 0 && d %it->first == 0 &&ada[tc] && ada[tl]&& ada[td])
		{
			c = c/it->first;
			l = it->first;
			d = d/it->first;

			break;
		}
	}
//	if(ada[a] == 0 || ada[k] == 0 || ada[b] == 0 || ada[l] == 0 || ada[c] == 0 || ada[d] == 0) cout<<5/0<<endl;
	cout<<"! "<<a<<" "<<k<<" "<<b<<" "<<c<<" "<<l<<" "<<d<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
	ll a , b,c,d;
	cout<<"? "<<1<<" "<<2<<endl;
	fflush(stdout);
	cin>>a;
	cout<<"? "<<2<<" "<<3<<endl;
	fflush(stdout);
	cin>>b;
	cout<<"? "<<4<<" "<<5<<endl;
	fflush(stdout);
	cin>>c;
	cout<<"? "<<5<<" "<<6<<endl;
	fflush(stdout);
	cin>>d;
	map <ll,ll> ada;
	ada[4] = 1;
	ada[8] = 1;
	ada[16] = 1;
	ada[23] = 1;
	ada[42] = 1;
	ada[15] = 1;
	map<ll,ll> :: iterator it;
	ll k , l;
	for(it = ada.begin() ; it != ada.end() ; ++it)
	{
			ll ta = a/it->first;
//			if(a%it->first !=0) continue;
			ll tk = it->first;

			ll tb = b/it->first;
//			if(b%it->first != 0) tb = -1;
		if(a%it->first == 0 && b %it->first == 0 && ada.count(ta)>0 && ada.count(tk)>0 && ada.count(tb) > 0)
		{
			a = a/it->first;
			k = it->first;
			b = b/it->first;
			ada.erase(a);
			ada.erase(k);
			ada.erase(b);
			break;
		}
	}
	if(ada.size() == 6) cout<<5/0<<endl;
	for(it = ada.begin() ; it != ada.end() ; ++it)
	{
		ll	tc = c/it->first;
//		if(c%it->first !=0) continue;
		ll	tl = it->first;
		ll	td = d/it->first;
//		if(d%it->first != 0) td = -1;
		if(c%it->first == 0 && d %it->first == 0 && ada.count(tc)>0 && ada.count(tl) >0&& ada.count(td)>0)
		{
			c = c/it->first;
			l = it->first;
			d = d/it->first;

			break;
		}
	}
//	if(ada[a] == 0 || ada[k] == 0 || ada[b] == 0 || ada[l] == 0 || ada[c] == 0 || ada[d] == 0) cout<<5/0<<endl;
	cout<<"! "<<a<<" "<<k<<" "<<b<<" "<<c<<" "<<l<<" "<<d<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
	ll a , b,c,d;
	cout<<"? "<<1<<" "<<2<<endl;
	fflush(stdout);
	cin>>a;
	cout<<"? "<<2<<" "<<3<<endl;
	fflush(stdout);
	cin>>b;
	cout<<"? "<<4<<" "<<5<<endl;
	fflush(stdout);
	cin>>c;
	cout<<"? "<<5<<" "<<6<<endl;
	fflush(stdout);
	cin>>d;
	map <ll,ll> ada;
	ada[4] = 1;
	ada[8] = 1;
	ada[16] = 1;
	ada[23] = 1;
	ada[42] = 1;
	ada[15] = 1;
	map<ll,ll> :: iterator it;
	ll k , l;
	for(it = ada.begin() ; it != ada.end() ; ++it)
	{
			ll ta = a/it->first;
			ll tk = it->first;
			ll tb = b/it->first;
		if(a%it->first == 0 && b %it->first == 0 && ada.count(ta) && ada.count(tk) && ada.count(tb))
		{
			a = a/it->first;
			k = it->first;
			b = b/it->first;

			break;
		}
	}
	for(it = ada.begin() ; it != ada.end() ; ++it)
	{
		ll	tc = c/it->first;
		ll	tl = it->first;
		ll	td = d/it->first;
		if(c%it->first == 0 && d %it->first == 0 && ada.count(tc) && ada.count(tl) && ada.count(td))
		{
			c = c/it->first;
			l = it->first;
			d = d/it->first;
			break;
		}
	}

	cout<<"! "<<a<<" "<<k<<" "<<b<<" "<<c<<" "<<l<<" "<<d<<endl;
	return 0;
}