// 去吧！皮卡丘! 把AC带回来！
//      へ　　　　　／|
// 　　/＼7　　　 ∠＿/
// 　 /　│　　 ／　／
// 　│　Z ＿,＜　／　　 /`ヽ
// 　│　　　　　ヽ　　 /　　〉
// 　Y　　　　　`　 /　　/
// 　ｲ●　､　●　　⊂⊃〈　　/
// 　()　 へ　　　　|　＼〈
// 　　>ｰ ､_　 ィ　 │ ／／`
// 　 / へ　　 /　ﾉ＜| ＼＼
// 　 ヽ_ﾉ　　(_／　 │／／
// 　　 7　　　　　　　|／
// 　　 ＞―r￣￣`ｰ―＿
//**************************************
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>
#include <stack>
#include <string.h>
#include <queue>
#include <math.h>
#include <cmath>
#include <set>
#include <time.h>
#include <unordered_map>
#include <bits/stdc++.h>
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug(x) cout << #x << ": " << x << endl
#define debug2(x,y) cout<< #x<<": "<<x<<' '<<#y<<": "<<y<<endl;
#define debugs  cout<<"ssssss"<<endl
#define debugx  cout<<"xxxxxx"<<endl
#define __count(x) __builtin_popcount(x)
//返回二进制下有多少个1  int范围 后加l是 unsigned long 加ll是 unsigned long long
#define __ctz(x) __builtin_ctz(x)           //返回二进制下末尾有几个零
#define __ffs(x) __builtin_ffs(x)           //返回二进制下最后一个1的位置，从1开始
#define __max_elenment *max_element		   //返回一个数组的最大值,参数是数组的起始位置和结束位置
#define __min_elenment *min_element

using namespace std;

const double pi=acos(-1);
typedef pair<int,int>pii;
#define mak make_pair
#define pll pair<ll,ll>
#define pub push_back
#define fi first
#define se second
#define sc scanf
#define pr printf
template<typename T>
inline T read()
{
    T s=0,f=1;
    char ch = getchar();
    while(!isdigit(ch))
    {
        if(ch == '-')
            f=-1;
        ch = getchar();
    }
    while(isdigit(ch))
    {
        s=(s<<3)+(s<<1)+ch-48;
        ch = getchar();
    }
    return s*f;
}
#define gi() read<int>()
#define gl() read<ll>()
template<typename T>
inline void print(T x)
{
    if(x<0)
        putchar('-'), x=-x;
    if(x>9)
        print(x/10);
    putchar(x%10+'0');
}
typedef long long ll;
const int maxx=1e6+10;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int MOD=998244353;
int gcd(int a,int b)
{
    return b==0?a:gcd(b,a%b);
}
//int get_id(ll x) {
//    return lower_bound(g.begin(), g.end(), x) - g.begin() + 1;
//}
///Codeforces Round #685 (Div. 2)
///E2. Bitwise Queries (Hard Version)

///E1. Bitwise Queries (Easy Version)
ll n;
int a[1<<17];
map<int,int>mp;
int get_num(int op,int x,int y){
  int kk;
 if(op==1) cout<<"XOR "<<x<<' '<<y<<endl;
 if(op==2) cout<<"AND "<<x<<' '<<y<<endl;
 if(op==3) cout<<"OR "<<x<<' '<<y<<endl;
    cin>>kk;
  return kk;
}
int main(){
     cin>>n;
     int id=-1;
     mp[0]=1;
     for(int i=2;i<=n;i++){
        int num=get_num(1,1,i);
        a[i]=num;
         if(!mp[num]) mp[num]=i;
         else id=i;
     }
     if(id!=-1) {
         int kk=get_num(2,id,mp[a[id]]);
         a[1]=kk^a[id];
         cout<<"! "<<a[1]<<' ';
         for(int i=2;i<=n;i++){
            cout<<(a[1]^a[i])<<' ';
         }
         cout<<endl;
     }
    else {
         int kk1=get_num(1,1,mp[1]);
         int kk2=get_num(1,1,mp[2]);
         int ans=kk1+kk2%2;
         cout<<"! ";
         for(int i=1;i<=n;i++){
             cout<<(ans^a[i])<<' ';
         }
         cout<<endl;
    }
    return 0;
}


// 去吧！皮卡丘! 把AC带回来！
//      へ　　　　　／|
// 　　/＼7　　　 ∠＿/
// 　 /　│　　 ／　／
// 　│　Z ＿,＜　／　　 /`ヽ
// 　│　　　　　ヽ　　 /　　〉
// 　Y　　　　　`　 /　　/
// 　ｲ●　､　●　　⊂⊃〈　　/
// 　()　 へ　　　　|　＼〈
// 　　>ｰ ､_　 ィ　 │ ／／`
// 　 / へ　　 /　ﾉ＜| ＼＼
// 　 ヽ_ﾉ　　(_／　 │／／
// 　　 7　　　　　　　|／
// 　　 ＞―r￣￣`ｰ―＿
//**************************************
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>
#include <stack>
#include <string.h>
#include <queue>
#include <math.h>
#include <cmath>
#include <set>
#include <time.h>
#include <unordered_map>
#include <bits/stdc++.h>
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug(x) cout << #x << ": " << x << endl
#define debug2(x,y) cout<< #x<<": "<<x<<' '<<#y<<": "<<y<<endl;
#define debugs  cout<<"ssssss"<<endl
#define debugx  cout<<"xxxxxx"<<endl
#define __count(x) __builtin_popcount(x)
//返回二进制下有多少个1  int范围 后加l是 unsigned long 加ll是 unsigned long long
#define __ctz(x) __builtin_ctz(x)           //返回二进制下末尾有几个零
#define __ffs(x) __builtin_ffs(x)           //返回二进制下最后一个1的位置，从1开始
#define __max_elenment *max_element		   //返回一个数组的最大值,参数是数组的起始位置和结束位置
#define __min_elenment *min_element

using namespace std;

const double pi=acos(-1);
typedef pair<int,int>pii;
#define mak make_pair
#define pll pair<ll,ll>
#define pub push_back
#define fi first
#define se second
#define sc scanf
#define pr printf
template<typename T>
inline T read()
{
    T s=0,f=1;
    char ch = getchar();
    while(!isdigit(ch))
    {
        if(ch == '-')
            f=-1;
        ch = getchar();
    }
    while(isdigit(ch))
    {
        s=(s<<3)+(s<<1)+ch-48;
        ch = getchar();
    }
    return s*f;
}
#define gi() read<int>()
#define gl() read<ll>()
template<typename T>
inline void print(T x)
{
    if(x<0)
        putchar('-'), x=-x;
    if(x>9)
        print(x/10);
    putchar(x%10+'0');
}
typedef long long ll;
const int maxx=1e6+10;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int MOD=998244353;
int gcd(int a,int b)
{
    return b==0?a:gcd(b,a%b);
}
//int get_id(ll x) {
//    return lower_bound(g.begin(), g.end(), x) - g.begin() + 1;
//}
///Codeforces Round #685 (Div. 2)
///E2. Bitwise Queries (Hard Version)
ll n;
int a[1<<17];
map<int,int>mp;
int get_num(int op,int x,int y){
  int kk;
 if(op==1) cout<<"XOR "<<x<<' '<<y<<endl;
 if(op==2) cout<<"AND "<<x<<' '<<y<<endl;
 if(op==3) cout<<"OR "<<x<<' '<<y<<endl;
    cin>>kk;
  return kk;
}
int main(){
     cin>>n;
     int id=-1;
     mp[0]=1;
     for(int i=2;i<=n;i++){
        int num=get_num(1,1,i);
        a[i]=num;
         if(!mp[num]) mp[num]=i;
         else id=i;
     }
     if(id!=-1) {
         int kk=get_num(2,id,mp[a[id]]);
         a[1]=kk^a[id];
         cout<<"! "<<a[1]<<' ';
         for(int i=2;i<=n;i++){
            cout<<(a[1]^a[i])<<' ';
         }
         cout<<endl;
     }
    else {
         int kk1=get_num(2,1,mp[1]);
         int kk2=get_num(2,1,mp[2]);
         int ans=kk1+kk2%2;
         cout<<"! ";
         for(int i=1;i<=n;i++){
             cout<<(ans^a[i])<<' ';
         }
         cout<<endl;
    }
    return 0;
}


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

void solve() {
    int n;
    cin >> n;
    int arr[n], cnt[n], flag = -1;
    memset(cnt, 0, sizeof(cnt));
    for(int i=1; i<n; i++) {
        cout << "XOR 1 " << i+1 << endl;
        cin >> arr[i];
        if(cnt[arr[i]])
            flag = arr[i];
    }
    if(flag>=0) {
        int p = 0, q = 0, x;
        for(int i=1; i<n; i++) {
            if(arr[i]==flag) {
                if(!p)
                    p = i+1;
                else if(!q)
                    q = i+1;
                else
                    break;
            }
        }
        cout << "OR " << p << ' ' << q << endl;
        cin >> x;
        arr[0] = arr[p-1]^x;
        cout << "! " << arr[0];
        for(int i=1; i<n; i++) {
            arr[i] ^= arr[0];
            cout << " " << arr[i];
        }
        return;
    }
    int p, q, x, y, z, temp;
    for(int i=1; i<n; i++) {
        if(arr[i]==n-1) {
            p = i+1;
            break;
        }
    }
    if(p==n)
        q = n-1;
    else
        q = p+1;
    x = n-1;
    cout << "AND 1 " << q << endl;
    cin >> temp;
    y = arr[q-1] + 2*temp;
    cout << "AND " << p << " " << q << endl;
    cin >> temp;
    z = arr[p-1]^arr[q-1]+2*temp;
    arr[0] = (x+y+z)/2-z;
    cout << "! " << arr[0];
    for(int i=1; i<n; i++) {
        arr[i] ^= arr[0];
        cout << " " << arr[i];
    }
    return;
}

signed main() {
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //int _t; cin >> _t; while(_t--)
    solve();
}


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

void solve() {
    int n;
    cin >> n;
    int arr[n], cnt[n], flag = -1;
    memset(cnt, 0, sizeof(cnt));
    for(int i=1; i<n; i++) {
        cout << "XOR 1 " << i+1 << endl;
        cin >> arr[i];
        if(cnt[arr[i]])
            flag = arr[i];
        cnt[arr[i]]++;
    }
    if(flag>=0) {
        int p = 0, q = 0, x;
        for(int i=1; i<n; i++) {
            if(arr[i]==flag) {
                if(!p)
                    p = i+1;
                else if(!q)
                    q = i+1;
                else
                    break;
            }
        }
        cout << "OR " << p << ' ' << q << endl;
        cin >> x;
        arr[0] = arr[p-1]^x;
        cout << "! " << arr[0];
        for(int i=1; i<n; i++) {
            arr[i] ^= arr[0];
            cout << " " << arr[i];
        }
        return;
    }
    int p, q, x, y, z, temp;
    for(int i=1; i<n; i++) {
        if(arr[i]==n-1) {
            p = i+1;
            break;
        }
    }
    if(p==n)
        q = n-1;
    else
        q = p+1;
    x = n-1;
    cout << "AND 1 " << q << endl;
    cin >> temp;
    y = arr[q-1] + 2*temp;
    cout << "AND " << p << " " << q << endl;
    cin >> temp;
    z = arr[p-1]^arr[q-1]+2*temp;
    arr[0] = (x+y+z)/2-z;
    cout << "! " << arr[0];
    for(int i=1; i<n; i++) {
        arr[i] ^= arr[0];
        cout << " " << arr[i];
    }
    return;
}

signed main() {
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //int _t; cin >> _t; while(_t--)
    solve();
}


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

void solve() {
    int n;
    cin >> n;
    int arr[n], cnt[n], flag = -1;
    memset(cnt, 0, sizeof(cnt));
    for(int i=1; i<n; i++) {
        cout << "XOR 1 " << i+1 << endl;
        cin >> arr[i];
        if(cnt[arr[i]])
            flag = arr[i];
        cnt[arr[i]]++;
    }
    if(flag>=0) {
        int p = 0, q = 0, x;
        for(int i=1; i<n; i++) {
            if(arr[i]==flag) {
                if(!p)
                    p = i+1;
                else if(!q)
                    q = i+1;
                else
                    break;
            }
        }
        cout << "OR " << p << ' ' << q << endl;
        cin >> x;
        arr[0] = arr[p-1]^x;
        cout << "! " << arr[0];
        for(int i=1; i<n; i++) {
            arr[i] ^= arr[0];
            cout << " " << arr[i];
        }
        return;
    }
    int p, q, x, y, z, temp;
    for(int i=1; i<n; i++) {
        if(arr[i]==n-1) {
            p = i+1;
            break;
        }
    }
    if(p==n)
        q = n-1;
    else
        q = p+1;
    x = n-1;
    cout << "AND 1 " << q << endl;
    cin >> temp;
    y = arr[q-1] + 2*temp;
    cout << "AND " << p << " " << q << endl;
    cin >> temp;
    z = (arr[p-1]^arr[q-1])+2*temp;
    arr[0] = (x+y+z)/2-z;
    cout << "! " << arr[0];
    for(int i=1; i<n; i++) {
        arr[i] ^= arr[0];
        cout << " " << arr[i];
    }
    return;
}

signed main() {
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //int _t; cin >> _t; while(_t--)
    solve();
}


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

const int N = 1 << 17;

int n, q;
int a[N], xorsum[N];
bool vis[N];

void ask(string type, int x, int y) {
    cout << type << " " << x << " " << y << endl;
    fflush(stdout);
}

int receive() {
    int res;
    cin >> res;
    return res;
}

void answer() {
    cout << "!";
    for (int i = 1; i <= n; i++) {
        cout << " " << a[i];
    }
    cout << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 2; i <= n; i++) {
        ask("XOR", 1, i);
        xorsum[i] = receive();
    }
    map<int, int> state;
    pair<int, int> same_val = make_pair(0, 0);
    for (int i = 2; i <= n; i++) {
        if (state[xorsum[i]] != 0) {
            same_val = make_pair(i, state[xorsum[i]]);
            break;
        }
        if (xorsum[i] == 0) {
            same_val = make_pair(1, i);
            break;
        }
        state[xorsum[i]] = i;
    }
    if (same_val.first == 0) {
        map<int, int> cnt;
        for (int i = 2; i <= n; i++) {
            if (cnt[xorsum[i]] == 0 && cnt[xorsum[i] ^ (n - 1)] == 0) {
                cnt[xorsum[i]] = i;
                cnt[xorsum[i] ^ (n - 1)] = i;
            } else {
                vis[cnt[xorsum[i]]] = true;
                vis[i] = true;
            }
        }
        int single = -1;
        for (int i = 2; i <= n; i++) {
            if (!vis[i]) single = i;
        }
        int target = 2;
        if (single == 2) target = 3;
        ask("AND", 1, target);
        int v1 = receive();
        ask("AND", single, target);
        int v2 = receive();
        a[1] = (v1 + v2) ^ xorsum[target];

    } else {
        ask("AND", same_val.first, same_val.second);
        int v = receive();
        a[1] = xorsum[same_val.first] ^ v;
    }
    for (int i = 2; i <= n; i++) {
        a[i] = a[1] ^ xorsum[i];
    }
    answer();
    return 0;
}


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

const int N = 1 << 17;

int n, q;
int a[N], xorsum[N];
bool vis[N];

void ask(string type, int x, int y) {
    cout << type << " " << x << " " << y << endl;
    fflush(stdout);
}

int receive() {
    int res;
    cin >> res;
    return res;
}

void answer() {
    cout << "!";
    for (int i = 1; i <= n; i++) {
        cout << " " << a[i];
    }
    cout << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 2; i <= n; i++) {
        ask("XOR", 1, i);
        xorsum[i] = receive();
    }
    map<int, int> state;
    pair<int, int> same_val = make_pair(0, 0);
    for (int i = 2; i <= n; i++) {
        if (state[xorsum[i]] != 0) {
            same_val = make_pair(i, state[xorsum[i]]);
        }
        state[xorsum[i]] = i;
    }
    if (same_val.first == 0) {
        map<int, int> cnt;
        for (int i = 2; i <= n; i++) {
            if (cnt[xorsum[i]] == 0 && cnt[xorsum[i] ^ (n - 1)] == 0) {
                cnt[xorsum[i]] = i;
                cnt[xorsum[i] ^ (n - 1)] = i;
            } else {
                vis[cnt[xorsum[i]]] = true;
                vis[i] = true;
            }
        }
        int single = -1;
        for (int i = 2; i <= n; i++) {
            if (!vis[i]) single = i;
        }
        int target = 2;
        if (single == 2) target = 3;
        ask("AND", 1, target);
        int v1 = receive();
        ask("AND", single, target);
        int v2 = receive();
        a[1] = (v1 + v2) ^ xorsum[target];

    } else {
        ask("AND", same_val.first, same_val.second);
        int v = receive();
        a[1] = xorsum[same_val.first] ^ v;
    }
    for (int i = 2; i <= n; i++) {
        a[i] = a[1] ^ xorsum[i];
    }
    answer();
    return 0;
}


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

const int N = 1 << 17;

int n, q;
int a[N], xorsum[N];
bool vis[N];

void ask(string type, int x, int y) {
    cout << type << " " << x << " " << y << endl;
    fflush(stdout);
}

int receive() {
    int res;
    cin >> res;
    return res;
}

void answer() {
    cout << "!";
    for (int i = 1; i <= n; i++) {
        cout << " " << a[i];
    }
    cout << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 2; i <= n; i++) {
        ask("XOR", 1, i);
        xorsum[i] = receive();
    }
    map<int, int> state;
    pair<int, int> same_val = make_pair(0, 0);
    for (int i = 2; i <= n; i++) {
        if (state[xorsum[i]] != 0) {
            same_val = make_pair(i, state[xorsum[i]]);
        }
        state[xorsum[i]] = i;
    }
    if (same_val.first != 0) {
        map<int, int> cnt;
        for (int i = 2; i <= n; i++) {
            if (cnt[xorsum[i]] == 0 && cnt[xorsum[i] ^ (n - 1)] == 0) {
                cnt[xorsum[i]] = i;
                cnt[xorsum[i] ^ (n - 1)] = i;
            } else {
                vis[cnt[xorsum[i]]] = true;
                vis[i] = true;
            }
        }
        int single = -1;
        for (int i = 2; i <= n; i++) {
            if (!vis[i]) single = i;
        }
        int target = 2;
        if (single == 2) target = 3;
        ask("AND", 1, target);
        int v1 = receive();
        ask("AND", single, target);
        int v2 = receive();
        a[1] = (v1 + v2) ^ xorsum[target];

    } else {
        ask("AND", same_val.first, same_val.second);
        int v = receive();
        a[1] = xorsum[same_val.first] ^ v;
    }
    for (int i = 2; i <= n; i++) {
        a[i] = a[1] ^ xorsum[i];
    }
    answer();
    return 0;
}


#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define ini(x, y) memset(x, y, sizeof(x));
#define FOR(i, j, k) for(int i = j; i<=k; i++)
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;
const int MAX = 2e9;
const double PI = acos(-1);

int xo[100000];
int ans[100000];
int main(void) {
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	//	freopen("input.txt", "r", stdin);
	int n; cin >> n;
	map<int, int>mp;
	int a, b;
	a = b = -1;
	for (int i = 2; i <= n; i++) {
		cout << "XOR 1 " << i << endl;
		cin >> xo[i];
		if (mp[xo[i]] > 0) {
			a = mp[xo[i]];
			b = i;
		}
		else {
			mp[xo[i]] = i;
		}
	}
	if (a == -1) { //같은게 없음
		int idx;
		for (int i = 2; i <= n; i++) {
			if (xo[i] == n-1) {
				idx = i;
				break;
			}
		}
		cout << "AND 1 2" << endl;
		int a, b; cin >> a;
		cout << "AND " << idx << ' ' << 2 << endl;
		cin >> b;
		ans[2] = a | b;
		for (int i = 0; i <= 16; i++) {
			if (xo[2] & (1 << i)) {
				if ((ans[2] & (1 << i)) == 0) ans[1] += (1 << i);
			}
			else {
				if (ans[2] & (1 << i)) ans[1] += (1 << i);
			}
		}
		for (int i = 3; i <= n; i++) {
			for (int j = 0; j <= 16; j++) {
				if (xo[i] & (1 << j)) {
					if ((ans[1] & (1 << j)) == 0) ans[i] += (1 << j);
				}
				else {
					if (ans[1] & (1 << j)) ans[i] += (1 << j);
				}
			}
		}
	}
	else {
		cout << "AND " << a << ' ' << b << endl;
		cin >> ans[a];
		cout << "XOR " << 1 << ' ' << a << endl;
		int val; cin >> val;
		for (int i = 0; i <= 16; i++) {
			if (val & (1 << i)) {
				if ((ans[a] & (1 << i)) == 0) ans[1] += (1 << i);
			}
			else {
				if ((ans[a] & (1 << i))) ans[1] += (1 << i);
			}
		}
		for (int i = 2; i <= n; i++) {
			if (i != a) {
				for (int j = 0; j <= 16; j++) {
					if (xo[i] & (1 << j)) {
						if ((ans[1] & (1 << j)) == 0) ans[i] += (1 << j);
					}
					else {
						if (ans[1] & (1 << j)) ans[i] += (1 << j);
					}
				}
			}
		}
	}
	cout << "! ";
	for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
	cout << endl;
}


#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define ini(x, y) memset(x, y, sizeof(x));
#define FOR(i, j, k) for(int i = j; i<=k; i++)
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;
const int MAX = 2e9;
const double PI = acos(-1);

int xo[100000];
int ans[100000];
int main(void) {
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	//	freopen("input.txt", "r", stdin);
	int n; cin >> n;
	map<int, int>mp;
	int a, b;
	a = b = -1;
	for (int i = 2; i <= n; i++) {
		cout << "XOR 1 " << i << endl;
		cin >> xo[i];
		if (mp[xo[i]] > 0) {
			a = mp[xo[i]];
			b = i;
		}
		else {
			mp[xo[i]] = i;
		}
	}
	if (a == -1) { //같은게 없음
		int idx;
		for (int i = 2; i <= n; i++) {
			if (xo[i] == ((1 << n) - 1)) {
				idx = i;
				break;
			}
		}
		cout << "AND 1 2" << endl;
		int a, b; cin >> a;
		cout << "AND " << idx << ' ' << 2 << endl;
		cin >> b;
		ans[2] = a | b;
		for (int i = 1; i <= n; i++) {
			if (i != 2) {
				for (int j = 0; j <= 16; j++) {
					if (xo[i] & (1 << j)) {
						if ((ans[2] & (1 << j)) == 0) ans[i] += (1 << j);
					}
					else {
						if (ans[2] & (1 << j)) ans[i] += (1 << j);
					}
				}
			}
		}
	}
	else { //
		cout << "AND " << a << ' ' << b << endl;
		cin >> ans[a];
		cout << "XOR " << 1 << ' ' << a << endl;
		int val; cin >> val;
		for (int i = 0; i <= 16; i++) {
			if (val & (1 << i)) {
				if ((ans[a] & (1 << i)) == 0) ans[1] += (1 << i);
			}
			else {
				if ((ans[a] & (1 << i))) ans[1] += (1 << i);
			}
		}
		for (int i = 2; i <= n; i++) {
			if (i != a) {
				for (int j = 0; j <= 16; j++) {
					if (xo[i] & (1 << j)) {
						if ((ans[1] & (1 << j)) == 0) ans[i] += (1 << j);
					}
					else {
						if (ans[1] & (1 << j)) ans[i] += (1 << j);
					}
				}
			}
		}
	}
	cout << "! ";
	for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
	cout << endl;
}


#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define ini(x, y) memset(x, y, sizeof(x));
#define FOR(i, j, k) for(int i = j; i<=k; i++)
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;
const int MAX = 2e9;
const double PI = acos(-1);

int xo[100000];
int ans[100000];
int main(void) {
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	//	freopen("input.txt", "r", stdin);
	int n; cin >> n;
	map<int, int>mp;
	int a, b;
	a = b = -1;
	for (int i = 2; i <= n; i++) {
		cout << "XOR 1 " << i << endl;
		cin >> xo[i];
	}
	for (int i = 2; i <= n; i++) {
		if (mp[xo[i]] > 0 ) {
			a = mp[xo[i]];
			b = i;
			break;
		}
		else if (xo[i] == 0) {
			a = 1;
			b = i;
			break;
		}
		else {
			mp[xo[i]] = i;
		}
	}
	if (a == -1) { //같은게 없음
		int idx;
		for (int i = 2; i <= n; i++) {
			if (xo[i] == n-1) {
				idx = i;
				break;
			}
		}
		cout << "AND 1 2" << endl;
		int a, b; cin >> a;
		cout << "AND " << idx << ' ' << 2 << endl;
		cin >> b;
		ans[2] = a | b;
		for (int i = 0; i <= 16; i++) {
			if (xo[2] & (1 << i)) {
				if ((ans[2] & (1 << i)) == 0) ans[1] += (1 << i);
			}
			else {
				if (ans[2] & (1 << i)) ans[1] += (1 << i);
			}
		}
		for (int i = 3; i <= n; i++) {
			for (int j = 0; j <= 16; j++) {
				if (xo[i] & (1 << j)) {
					if ((ans[1] & (1 << j)) == 0) ans[i] += (1 << j);
				}
				else {
					if (ans[1] & (1 << j)) ans[i] += (1 << j);
				}
			}
		}
	}
	else {
		if (a == 1) {
			cout << "AND " << a << ' ' << b << endl;
			cin >> ans[1];
		}
		else {
			cout << "AND " << a << ' ' << b << endl;
			cin >> ans[a];
			cout << "XOR " << 1 << ' ' << a << endl;
			int val; cin >> val;
			for (int i = 0; i <= 16; i++) {
				if (val & (1 << i)) {
					if ((ans[a] & (1 << i)) == 0) ans[1] += (1 << i);
				}
				else {
					if ((ans[a] & (1 << i))) ans[1] += (1 << i);
				}
			}
		}
		for (int i = 2; i <= n; i++) {
			if (i != a) {
				for (int j = 0; j <= 16; j++) {
					if (xo[i] & (1 << j)) {
						if ((ans[1] & (1 << j)) == 0) ans[i] += (1 << j);
					}
					else {
						if (ans[1] & (1 << j)) ans[i] += (1 << j);
					}
				}
			}
		}
	}
	cout << "! ";
	for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
	cout << endl;
}


#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define ini(x, y) memset(x, y, sizeof(x));
#define FOR(i, j, k) for(int i = j; i<=k; i++)
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;
const int MAX = 2e9;
const double PI = acos(-1);

int xo[100000];
int ans[100000];
int main(void) {
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	//	freopen("input.txt", "r", stdin);
	int n; cin >> n;
	map<int, int>mp;
	int a, b;
	a = b = -1;
	mp[0] = 1;
	for (int i = 2; i <= n; i++) {
		cout << "XOR 1 " << i << endl;
		cin >> xo[i];
		if (mp[xo[i]] > 0) {
			a = mp[xo[i]];
			b = i;
		}
		else {
			mp[xo[i]] = i;
		}
	}
	if (a == -1) { //같은게 없음
		int idx;
		for (int i = 2; i <= n; i++) {
			if (xo[i] == n-1) {
				idx = i;
				break;
			}
		}
		cout << "AND 1 2" << endl;
		int a, b; cin >> a;
		cout << "AND " << idx << ' ' << 2 << endl;
		cin >> b;
		ans[2] = a | b;
		for (int i = 0; i <= 16; i++) {
			if (xo[2] & (1 << i)) {
				if ((ans[2] & (1 << i)) == 0) ans[1] += (1 << i);
			}
			else {
				if (ans[2] & (1 << i)) ans[1] += (1 << i);
			}
		}
		for (int i = 3; i <= n; i++) {
			for (int j = 0; j <= 16; j++) {
				if (xo[i] & (1 << j)) {
					if ((ans[1] & (1 << j)) == 0) ans[i] += (1 << j);
				}
				else {
					if (ans[1] & (1 << j)) ans[i] += (1 << j);
				}
			}
		}
	}
	else {
		cout << "AND " << a << ' ' << b << endl;
		cin >> ans[a];
		cout << "XOR " << 1 << ' ' << a << endl;
		int val; cin >> val;
		for (int i = 0; i <= 16; i++) {
			if (val & (1 << i)) {
				if ((ans[a] & (1 << i)) == 0) ans[1] += (1 << i);
			}
			else {
				if ((ans[a] & (1 << i))) ans[1] += (1 << i);
			}
		}
		for (int i = 2; i <= n; i++) {
			if (i != a) {
				for (int j = 0; j <= 16; j++) {
					if (xo[i] & (1 << j)) {
						if ((ans[1] & (1 << j)) == 0) ans[i] += (1 << j);
					}
					else {
						if (ans[1] & (1 << j)) ans[i] += (1 << j);
					}
				}
			}
		}
	}
	cout << "! ";
	for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
	cout << endl;
}


#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define ini(x, y) memset(x, y, sizeof(x));
#define FOR(i, j, k) for(int i = j; i<=k; i++)
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;
const int MAX = 2e9;
const double PI = acos(-1);

int xo[100000];
int ans[100000];
int main(void) {
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	//	freopen("input.txt", "r", stdin);
	int n; cin >> n;
	map<int, int>mp;
	int a, b;
	a = b = -1;
	for (int i = 2; i <= n; i++) {
		cout << "XOR 1 " << i << endl;
		cin >> xo[i];
	}
	for (int i = 2; i <= n; i++) {
		if (mp[xo[i]] > 0 ) {
			a = mp[xo[i]];
			b = i;
			break;
		}
		else if (xo[i] == 0) {
			a = 1;
			b = i;
			break;
		}
		else {
			mp[xo[i]] = i;
		}
	}
	if (a == -1) { //같은게 없음
		int idx;
		for (int i = 2; i <= n; i++) {
			if (xo[i] == n-1) {
				idx = i;
				break;
			}
		}
		if (idx != 2) {
			cout << "AND 1 2" << endl;
			int a, b; cin >> a;
			cout << "AND " << idx << ' ' << 2 << endl;
			cin >> b;
			ans[2] = a | b;
			for (int i = 0; i <= 16; i++) {
				if (xo[2] & (1 << i)) {
					if ((ans[2] & (1 << i)) == 0) ans[1] += (1 << i);
				}
				else {
					if (ans[2] & (1 << i)) ans[1] += (1 << i);
				}
			}
			for (int i = 3; i <= n; i++) {
				for (int j = 0; j <= 16; j++) {
					if (xo[i] & (1 << j)) {
						if ((ans[1] & (1 << j)) == 0) ans[i] += (1 << j);
					}
					else {
						if (ans[1] & (1 << j)) ans[i] += (1 << j);
					}
				}
			}
		}
		else {
			cout << "AND 1 3" << endl;
			int a, b; cin >> a;
			cout << "AND " << idx << ' ' << 3 << endl;
			cin >> b;
			ans[3] = a | b;
			for (int i = 0; i <= 16; i++) {
				if (xo[3] & (1 << i)) {
					if ((ans[3] & (1 << i)) == 0) ans[1] += (1 << i);
				}
				else {
					if (ans[3] & (1 << i)) ans[1] += (1 << i);
				}
			}
			for (int i = 2; i <= n; i++) {
				if (i == 3) continue;
				for (int j = 0; j <= 16; j++) {
					if (xo[i] & (1 << j)) {
						if ((ans[1] & (1 << j)) == 0) ans[i] += (1 << j);
					}
					else {
						if (ans[1] & (1 << j)) ans[i] += (1 << j);
					}
				}
			}
		}

	}
	else {
		if (a == 1) {
			cout << "AND " << a << ' ' << b << endl;
			cin >> ans[1];
		}
		else {
			cout << "AND " << a << ' ' << b << endl;
			cin >> ans[a];
			cout << "XOR " << 1 << ' ' << a << endl;
			int val; cin >> val;
			for (int i = 0; i <= 16; i++) {
				if (val & (1 << i)) {
					if ((ans[a] & (1 << i)) == 0) ans[1] += (1 << i);
				}
				else {
					if ((ans[a] & (1 << i))) ans[1] += (1 << i);
				}
			}
		}
		for (int i = 2; i <= n; i++) {
			if (i != a) {
				for (int j = 0; j <= 16; j++) {
					if (xo[i] & (1 << j)) {
						if ((ans[1] & (1 << j)) == 0) ans[i] += (1 << j);
					}
					else {
						if (ans[1] & (1 << j)) ans[i] += (1 << j);
					}
				}
			}
		}
	}
	cout << "! ";
	for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
	cout << endl;
}


#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define ini(x, y) memset(x, y, sizeof(x));
#define FOR(i, j, k) for(int i = j; i<=k; i++)
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;
const int MAX = 2e9;
const double PI = acos(-1);

int xo[100000];
int ans[100000];
int main(void) {
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	//	freopen("input.txt", "r", stdin);
	int n; cin >> n;
	map<int, int>mp;
	int a, b;
	a = b = -1;
	for (int i = 2; i <= n; i++) {
		cout << "XOR 1 " << i << endl;
		cin >> xo[i];
		if (mp[xo[i]] > 0) {
			a = mp[xo[i]];
			b = i;
		}
		else {
			mp[xo[i]] = i;
		}
	}
	if (a == -1) { //같은게 없음
		int idx;
		for (int i = 2; i <= n; i++) {
			if (xo[i] == n-1) {
				idx = i;
				break;
			}
		}
		cout << "AND 1 2" << endl;
		int a, b; cin >> a;
		cout << "AND " << idx << ' ' << 2 << endl;
		cin >> b;
		ans[2] = a | b;
		for (int i = 1; i <= n; i++) {
			if (i != 2) {
				for (int j = 0; j <= 16; j++) {
					if (xo[i] & (1 << j)) {
						if ((ans[2] & (1 << j)) == 0) ans[i] += (1 << j);
					}
					else {
						if (ans[2] & (1 << j)) ans[i] += (1 << j);
					}
				}
			}
		}
	}
	else {
		cout << "AND " << a << ' ' << b << endl;
		cin >> ans[a];
		cout << "XOR " << 1 << ' ' << a << endl;
		int val; cin >> val;
		for (int i = 0; i <= 16; i++) {
			if (val & (1 << i)) {
				if ((ans[a] & (1 << i)) == 0) ans[1] += (1 << i);
			}
			else {
				if ((ans[a] & (1 << i))) ans[1] += (1 << i);
			}
		}
		for (int i = 2; i <= n; i++) {
			if (i != a) {
				for (int j = 0; j <= 16; j++) {
					if (xo[i] & (1 << j)) {
						if ((ans[1] & (1 << j)) == 0) ans[i] += (1 << j);
					}
					else {
						if (ans[1] & (1 << j)) ans[i] += (1 << j);
					}
				}
			}
		}
	}
	cout << "! ";
	for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
	cout << endl;
}


#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define ini(x, y) memset(x, y, sizeof(x));
#define FOR(i, j, k) for(int i = j; i<=k; i++)
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;
const int MAX = 2e9;
const double PI = acos(-1);

int xo[100000];
int ans[100000];
int main(void) {
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	//	freopen("input.txt", "r", stdin);
	int n; cin >> n;
	map<int, int>mp;
	int a, b;
	a = b = -1;
	for (int i = 2; i <= n; i++) {
		cout << "XOR 1 " << i << endl;
		cin >> xo[i];
	}
	for (int i = 2; i <= n; i++) {
		if (mp[xo[i]] > 0 ) {
			a = mp[xo[i]];
			b = i;
			break;
		}
		else if (xo[i] == 0) {
			a = 1;
			b = i;
			break;
		}
		else {
			mp[xo[i]] = i;
		}
	}
	if (a == -1) { //같은게 없음
		int idx;
		for (int i = 2; i <= n; i++) {
			if (xo[i] == n-1) {
				idx = i;
				break;
			}
		}
		cout << "AND 1 2" << endl;
		int a, b; cin >> a;
		cout << "AND " << idx << ' ' << 2 << endl;
		cin >> b;
		ans[2] = a | b;
		for (int i = 0; i <= 16; i++) {
			if (xo[2] & (1 << i)) {
				if ((ans[2] & (1 << i)) == 0) ans[1] += (1 << i);
			}
			else {
				if (ans[2] & (1 << i)) ans[1] += (1 << i);
			}
		}
		for (int i = 3; i <= n; i++) {
			for (int j = 0; j <= 16; j++) {
				if (xo[i] & (1 << j)) {
					if ((ans[1] & (1 << j)) == 0) ans[i] += (1 << j);
				}
				else {
					if (ans[1] & (1 << j)) ans[i] += (1 << j);
				}
			}
		}
	}
	else {
		cout << "AND " << a << ' ' << b << endl;
		cin >> ans[a];
		cout << "XOR " << 1 << ' ' << a << endl;
		int val; cin >> val;
		for (int i = 0; i <= 16; i++) {
			if (val & (1 << i)) {
				if ((ans[a] & (1 << i)) == 0) ans[1] += (1 << i);
			}
			else {
				if ((ans[a] & (1 << i))) ans[1] += (1 << i);
			}
		}
		for (int i = 2; i <= n; i++) {
			if (i != a) {
				for (int j = 0; j <= 16; j++) {
					if (xo[i] & (1 << j)) {
						if ((ans[1] & (1 << j)) == 0) ans[i] += (1 << j);
					}
					else {
						if (ans[1] & (1 << j)) ans[i] += (1 << j);
					}
				}
			}
		}
	}
	cout << "! ";
	for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
	cout << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define fr(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define speed   ios::sync_with_stdio(false), cin.tie(0) , cout.tie(0)
#define fillm(m,r,c,k) fr(i,0,r)fr(j,0,c)m[i][j]=k;
#define prm(m,r,c) fr(i,0,r){fr(j,0,c){cout<<m[i][j]<<" "; }cout<<endl;}
#define pr(a,n)fr(i,0,n)cout<<a[i]<<",";cout<<endl;
#define endl '\n'
#define MOD 1000000007
#define INF 1000000000
#define prv(v) for(auto x: v)cout<<x<<" ";cout<<endl;
#define MAX 400005
#define all(x) x.begin(),x.end()
#define mkp make_pair
#define ll long long
#define f first
#define s second
int main(){
    int n;cin>>n;
    int xor1[n+1];

    fr(i,2,n+1){
        cout<<"XOR "<<1<<" "<<i<<endl;
        cout.flush();
        cin>>xor1[i];
    }
    //pr(xor1,n+1);
    int v1 = 0;
    int seen[n+1];
    fr(i,0,n+1)
    {
        seen[i] = -1;
    }
    fr(i,2,n+1){
        if(seen[xor1[i]]!=-1){
            cout<<"AND "<<seen[xor1[i]]<<" "<<i<<endl;
            cout.flush();
            int x;
            cin>>x;
            v1 =  (xor1[i]^x);
            goto print;
        }
        else if(xor1[i] == 0){
            cout<<"AND "<<1<<" "<<i<<endl;
            cout.flush();
            int x;
            cin>>x;
            v1 = x;
            goto print;
        }
        else{
            seen[xor1[i]]=i;
        }
    }
    //if premutation
    fr(i,2,n+1){
        if(xor1[i] == 1){
            cout<<"AND "<<1<<" "<<i<<endl;
            cout.flush();
            int x;
            cin>>x;
            v1 = v1 | x;
            break;
        }

    }
    fr(i,2,n+1){
        if(((xor1[i])&1) == 0)
        {
            cout<<"AND"<<1<<" "<<i<<endl;
            int x;
            cin>>x;
            x = x&1;
            v1 = v1 | x;
            goto print;
        }
    }

    print:
    cout<<"!"<<" "<<v1<<" ";
    fr(i,2,n+1){
        cout<<(xor1[i]^v1)<<" ";
    }

return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fr(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define speed   ios::sync_with_stdio(false), cin.tie(0) , cout.tie(0)
#define fillm(m,r,c,k) fr(i,0,r)fr(j,0,c)m[i][j]=k;
#define prm(m,r,c) fr(i,0,r){fr(j,0,c){cout<<m[i][j]<<" "; }cout<<endl;}
#define pr(a,n)fr(i,0,n)cout<<a[i]<<",";cout<<endl;
#define endl '\n'
#define MOD 1000000007
#define INF 1000000000
#define prv(v) for(auto x: v)cout<<x<<" ";cout<<endl;
#define MAX 400005
#define all(x) x.begin(),x.end()
#define mkp make_pair
#define ll long long
#define f first
#define s second
int xor1[1000000];
int main(){
    int n;cin>>n;
    fr(i,2,n+1){
        cout<<"XOR "<<1<<" "<<i<<endl;
        cout.flush();
        cin>>xor1[i];
    }
    int v1 = 0;
    int seen[n+1];
    fr(i,0,n+1)
    {
        seen[i] = -1;
    }
    fr(i,2,n+1){
        if(seen[xor1[i]]!=-1){
            cout<<"AND "<<seen[xor1[i]]<<" "<<i<<endl;
            cout.flush();
            int x;
            cin>>x;
            v1 =  (xor1[i]^x);
            goto print;
        }
        else if(xor1[i] == 0){
            cout<<"AND "<<1<<" "<<i<<endl;
            cout.flush();
            int x;
            cin>>x;
            v1 = x;
            goto print;
        }
        else{
            seen[xor1[i]]=i;
        }
    }
    //if premutation
    fr(i,2,n+1){
        if(xor1[i] == 1){
            cout<<"AND "<<1<<" "<<i<<endl;
            cout.flush();
            int x;
            cin>>x;
            v1 = v1 | x;
            break;
        }

    }
    fr(i,2,n+1){
        if(((xor1[i])&1) == 0)
        {
            cout<<"AND "<<1<<" "<<i<<endl;
            int x;
            cin>>x;
            x = x&1;
            v1 = v1 | x;
            goto print;
        }
    }

    print:
    cout<<"!"<<" "<<v1<<" ";
    fr(i,2,n+1){
        cout<<(xor1[i]^v1)<<" ";
    }

return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fr(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define speed   ios::sync_with_stdio(false), cin.tie(0) , cout.tie(0)
#define fillm(m,r,c,k) fr(i,0,r)fr(j,0,c)m[i][j]=k;
#define prm(m,r,c) fr(i,0,r){fr(j,0,c){cout<<m[i][j]<<" "; }cout<<endl;}
#define pr(a,n)fr(i,0,n)cout<<a[i]<<",";cout<<endl;
#define endl '\n'
#define MOD 1000000007
#define INF 1000000000
#define prv(v) for(auto x: v)cout<<x<<" ";cout<<endl;
#define MAX 400005
#define all(x) x.begin(),x.end()
#define mkp make_pair
#define ll long long
#define f first
#define s second
int xor1[1000000];
int main(){
    int n;cin>>n;

    int a[n+1];
    fr(i,1,n+1)
        cin>>a[i];
    fr(i,2,n+1){
        cout<<"XOR "<<1<<" "<<i<<endl;
        cout.flush();
        cin>>xor1[i];
    }
    //pr(xor1,n+1);
    int v1 = 0;
    int seen[n+1];
    fr(i,0,n+1)
    {
        seen[i] = -1;
    }
    fr(i,2,n+1){
        if(seen[xor1[i]]!=-1){
            cout<<"AND "<<seen[xor1[i]]<<" "<<i<<endl;
            cout.flush();
            int x;
            cin>>x;
            v1 =  (xor1[i]^x);
            goto print;
        }
        else if(xor1[i] == 0){
            cout<<"AND "<<1<<" "<<i<<endl;
            cout.flush();
            int x;
            cin>>x;
            v1 = x;
            goto print;
        }
        else{
            seen[xor1[i]]=i;
        }
    }
    //if premutation
    fr(i,2,n+1){
        if(xor1[i] == 1){
            cout<<"AND "<<1<<" "<<i<<endl;
            cout.flush();
            int x;
            cin>>x;
            v1 = v1 | x;
            break;
        }

    }
    fr(i,2,n+1){
        if(((xor1[i])&1) == 0)
        {
            cout<<"AND "<<1<<" "<<i<<endl;
            int x;
            cin>>x;
            x = x&1;
            v1 = v1 | x;
            goto print;
        }
    }

    print:
    cout<<"!"<<" "<<v1<<" ";
    fr(i,2,n+1){
        cout<<(xor1[i]^v1)<<" ";
    }

return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fr(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define speed   ios::sync_with_stdio(false), cin.tie(0) , cout.tie(0)
#define fillm(m,r,c,k) fr(i,0,r)fr(j,0,c)m[i][j]=k;
#define prm(m,r,c) fr(i,0,r){fr(j,0,c){cout<<m[i][j]<<" "; }cout<<endl;}
#define pr(a,n)fr(i,0,n)cout<<a[i]<<",";cout<<endl;
#define endl '\n'
#define MOD 1000000007
#define INF 1000000000
#define prv(v) for(auto x: v)cout<<x<<" ";cout<<endl;
#define MAX 400005
#define all(x) x.begin(),x.end()
#define mkp make_pair
#define ll long long
#define f first
#define s second
int main(){
    int n;cin>>n;
    int xor1[n+1];
    int a[n+1];
    fr(i,1,n+1)
        cin>>a[i];
    fr(i,2,n+1){
        cout<<"XOR "<<1<<" "<<i<<endl;
        cout.flush();
        cin>>xor1[i];
    }
    //pr(xor1,n+1);
    int v1 = 0;
    int seen[n+1];
    fr(i,0,n+1)
    {
        seen[i] = -1;
    }
    fr(i,2,n+1){
        if(seen[xor1[i]]!=-1){
            cout<<"AND "<<seen[xor1[i]]<<" "<<i<<endl;
            cout.flush();
            int x;
            cin>>x;
            v1 =  (xor1[i]^x);
            goto print;
        }
        else if(xor1[i] == 0){
            cout<<"AND "<<1<<" "<<i<<endl;
            cout.flush();
            int x;
            cin>>x;
            v1 = x;
            goto print;
        }
        else{
            seen[xor1[i]]=i;
        }
    }
    //if premutation
    fr(i,2,n+1){
        if(xor1[i] == 1){
            cout<<"AND "<<1<<" "<<i<<endl;
            cout.flush();
            int x;
            cin>>x;
            v1 = v1 | x;
            break;
        }

    }
    fr(i,2,n+1){
        if(((xor1[i])&1) == 0)
        {
            cout<<"AND"<<1<<" "<<i<<endl;
            int x;
            cin>>x;
            x = x&1;
            v1 = v1 | x;
            goto print;
        }
    }

    print:
    cout<<"!"<<" "<<v1<<" ";
    fr(i,2,n+1){
        cout<<(xor1[i]^v1)<<" ";
    }

return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fr(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define speed   ios::sync_with_stdio(false), cin.tie(0) , cout.tie(0)
#define fillm(m,r,c,k) fr(i,0,r)fr(j,0,c)m[i][j]=k;
#define prm(m,r,c) fr(i,0,r){fr(j,0,c){cout<<m[i][j]<<" "; }cout<<endl;}
#define pr(a,n)fr(i,0,n)cout<<a[i]<<",";cout<<endl;
#define endl '\n'
#define MOD 1000000007
#define INF 1000000000
#define prv(v) for(auto x: v)cout<<x<<" ";cout<<endl;
#define MAX 400005
#define all(x) x.begin(),x.end()
#define mkp make_pair
#define ll long long
#define f first
#define s second
int xor1[1000000];
int main(){
    int n;cin>>n;

    int a[n+1];
    fr(i,1,n+1)
        cin>>a[i];
    fr(i,2,n+1){
        cout<<"XOR "<<1<<" "<<i<<endl;
        cout.flush();
        cin>>xor1[i];
    }
    //pr(xor1,n+1);
    int v1 = 0;
    int seen[n+1];
    fr(i,0,n+1)
    {
        seen[i] = -1;
    }
    fr(i,2,n+1){
        if(seen[xor1[i]]!=-1){
            cout<<"AND "<<seen[xor1[i]]<<" "<<i<<endl;
            cout.flush();
            int x;
            cin>>x;
            v1 =  (xor1[i]^x);
            goto print;
        }
        else if(xor1[i] == 0){
            cout<<"AND "<<1<<" "<<i<<endl;
            cout.flush();
            int x;
            cin>>x;
            v1 = x;
            goto print;
        }
        else{
            seen[xor1[i]]=i;
        }
    }
    //if premutation
    fr(i,2,n+1){
        if(xor1[i] == 1){
            cout<<"AND "<<1<<" "<<i<<endl;
            cout.flush();
            int x;
            cin>>x;
            v1 = v1 | x;
            break;
        }

    }
    fr(i,2,n+1){
        if(((xor1[i])&1) == 0)
        {
            cout<<"AND"<<1<<" "<<i<<endl;
            int x;
            cin>>x;
            x = x&1;
            v1 = v1 | x;
            goto print;
        }
    }

    print:
    cout<<"!"<<" "<<v1<<" ";
    fr(i,2,n+1){
        cout<<(xor1[i]^v1)<<" ";
    }

return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fr(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define speed   ios::sync_with_stdio(false), cin.tie(0) , cout.tie(0)
#define fillm(m,r,c,k) fr(i,0,r)fr(j,0,c)m[i][j]=k;
#define prm(m,r,c) fr(i,0,r){fr(j,0,c){cout<<m[i][j]<<" "; }cout<<endl;}
#define pr(a,n)fr(i,0,n)cout<<a[i]<<",";cout<<endl;
#define endl '\n'
#define MOD 1000000007
#define INF 1000000000
#define prv(v) for(auto x: v)cout<<x<<" ";cout<<endl;
#define MAX 400005
#define all(x) x.begin(),x.end()
#define mkp make_pair
#define ll long long
#define f first
#define s second
int xor1[1000000];
int main(){
    int n;cin>>n;

    int a[n+1];

    fr(i,2,n+1){
        cout<<"XOR "<<1<<" "<<i<<endl;
        cout.flush();
        cin>>xor1[i];
    }
    //pr(xor1,n+1);
    int v1 = 0;
    int seen[n+1];
    fr(i,0,n+1)
    {
        seen[i] = -1;
    }
    fr(i,2,n+1){
        if(seen[xor1[i]]!=-1){
            cout<<"AND "<<seen[xor1[i]]<<" "<<i<<endl;
            cout.flush();
            int x;
            cin>>x;
            v1 =  (xor1[i]^x);
            goto print;
        }
        else if(xor1[i] == 0){
            cout<<"AND "<<1<<" "<<i<<endl;
            cout.flush();
            int x;
            cin>>x;
            v1 = x;
            goto print;
        }
        else{
            seen[xor1[i]]=i;
        }
    }
    //if premutation
    fr(i,2,n+1){
        if(xor1[i] == 1){
            cout<<"AND "<<1<<" "<<i<<endl;
            cout.flush();
            int x;
            cin>>x;
            v1 = v1 | x;
            break;
        }

    }
    fr(i,2,n+1){
        if(((xor1[i])&1) == 0)
        {
            cout<<"AND "<<1<<" "<<i<<endl;
            int x;
            cin>>x;
            x = x&1;
            v1 = v1 | x;
            goto print;
        }
    }

    print:
    cout<<"!"<<" "<<v1<<" ";
    fr(i,2,n+1){
        cout<<(xor1[i]^v1)<<" ";
    }

return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fr(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define speed   ios::sync_with_stdio(false), cin.tie(0) , cout.tie(0)
#define fillm(m,r,c,k) fr(i,0,r)fr(j,0,c)m[i][j]=k;
#define prm(m,r,c) fr(i,0,r){fr(j,0,c){cout<<m[i][j]<<" "; }cout<<endl;}
#define pr(a,n)fr(i,0,n)cout<<a[i]<<",";cout<<endl;
#define endl '\n'
#define MOD 1000000007
#define INF 1000000000
#define prv(v) for(auto x: v)cout<<x<<" ";cout<<endl;
#define MAX 400005
#define all(x) x.begin(),x.end()
#define mkp make_pair
#define ll long long
#define f first
#define s second

int main(){
    int n;cin>>n;

    int a[n+1];
    int xor1[n+1];
    fr(i,2,n+1){
        cout<<"XOR "<<1<<" "<<i<<endl;
        cout.flush();
        cin>>xor1[i];
    }
    //pr(xor1,n+1);
    int v1 = 0;
    int seen[n+1];
    fr(i,0,n+1)
    {
        seen[i] = -1;
    }
    fr(i,2,n+1){
        if(seen[xor1[i]]!=-1){
            cout<<"AND "<<seen[xor1[i]]<<" "<<i<<endl;
            cout.flush();
            int x;
            cin>>x;
            v1 =  (xor1[i]^x);
            goto print;
        }
        else if(xor1[i] == 0){
            cout<<"AND "<<1<<" "<<i<<endl;
            cout.flush();
            int x;
            cin>>x;
            v1 = x;
            goto print;
        }
        else{
            seen[xor1[i]]=i;
        }
    }
    //if premutation
    fr(i,2,n+1){
        if(xor1[i] == 1){
            cout<<"AND "<<1<<" "<<i<<endl;
            cout.flush();
            int x;
            cin>>x;
            v1 = v1 | x;
            break;
        }

    }
    fr(i,2,n+1){
        if(((xor1[i])&1) == 0)
        {
            cout<<"AND "<<1<<" "<<i<<endl;
            int x;
            cin>>x;
            x = x&1;
            v1 = v1 | x;
            goto print;
        }
    }

    print:
    cout<<"!"<<" "<<v1<<" ";
    fr(i,2,n+1){
        cout<<(xor1[i]^v1)<<" ";
    }

return 0;
}


#include <bits/stdc++.h>
#include <random>
#include <ctime>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx2")
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define pii pair<int,int>
#define sqr(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define do_anal exit(0)

using namespace std;
//using namespace __gnu_pbds;

const ll MOD = 998244353;
const ll md = 11234549;
const ld PI = acosl(-1.0);
const ld E = 1e-15;
mt19937_64 rnd(time(0));
ll p1 = 227, p2 = 29 + rnd() % 100, md1 = MOD, md2 = MOD - rnd() % 1000;

//using ord_set=tree<T,null_type,less<T>,,tree_order_statistics_node_update>;

ll n, m, k, T, a[1000001];
bool tt[1001];

ll binpow(ll h, ll r, ll md)
{
    ll l = 1;
    while (r)
    {
        if (r & 1) l*=h, l%=md;
        h*=h;
        h%=md;
        r /= 2;
    }
    return l;
}

void solve()
{
    //cout << "----\n";
    cin >> n;
    vector<pll> v;
    ll x;
    for (int i = 2; i <= n; i++)
    {
        cout << "XOR 1 " << i << "\n";
        cin >> x;
        fflush(stdout);
        v.pb(mp(x, i));
    }
    sort(all(v));
    if (v[0].fi==0)
    {
        cout << "AND 1 " << v[0].se << "\n";
        cin >> x;
        cout << "! ";
        for (int i = 0; i < v.size(); i++) a[v[i].se]=v[i].fi^x;
        a[1]=x;
        for (int i = 1; i <= n; i++) cout << a[i] << " ";
        cout << "\n";
        return;
    }
    ll p=0;
    for (int i = 0; i < v.size()-1; i++)
        if (v[i].fi==v[i+1].fi)
        {
            cout << "AND " << v[i].se << " " << v[i+1].se << "\n";
            cin >> x;
            x=x^v[i].fi;
            fflush(stdout);
            cout << "! ";
            for (int i = 0; i < v.size(); i++) a[v[i].se]=v[i].fi^x;
            a[1]=x;
            for (int i = 1; i <= n; i++) cout << a[i] << " ";
            cout << "\n";
            return;
        }
    for (int i = 0; i < v.size()-1; i++)
        if (v[i].fi+1==v[i+1].fi)
        {
            cout << "AND " << v[i].se << " " << v[i+1].se << "\n";
            cin >> x;
            x^=v[i].fi;
            fflush(stdout);
            cout << "AND 1 " << v[i].se << "\n";
            ll p;
            cin >> p;
            fflush(stdout);
            if (p%2) x++;
            cout << "! ";
            for (int i = 0; i < v.size(); i++) a[v[i].se]=v[i].fi^x;
            a[1]=x;
            for (int i = 1; i <= n; i++) cout << a[i] << " ";
            cout << "\n";
            return;
        }
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("d.in","r",stdin);
    //freopen("d.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll t=1;
    //cin >> t;
    T=t;
    while (t--)
    {
        solve();
    }
    return 0;
}

/*
5
4
4 4
1 1
2 2
3 3
4
4 4
4 1
1 4
2 2
6
3 2
2 1
1 2
3 3
3 4
3 1
5
1 1
1 2
1 3
1 4
5 5
4
1000000000 1000000000
1000000000 1
2 2
1000000000 999999999

1
4
1 1
2 1
33 3
2 2
*/


#include <bits/stdc++.h>
#include <random>
#include <ctime>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx2")
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define pii pair<int,int>
#define sqr(a) ((a)*(a))
#define all(v) v.begin(),v.end()

using namespace std;
//using namespace __gnu_pbds;

const ll MOD = 998244353;
const ld PI = acosl(-1.0);
const ld E = 1e-15;
mt19937_64 rnd(time(0));
//ll p1 = 31, p2 = 29 + rnd() % 100, md1 = MOD, md2 = MOD - rnd() % 1000;

//using ord_set=tree<T,null_type,less<T>,,tree_order_statistics_node_update>;

ll n, m, a[1000001], dp[1000001];

ll binpow(ll h, ll r, ll md = MOD)
{
    ll l = 1;
    while (r)
    {
        if (r & 1) l *= h, l %= md;
        h *= h;
        h %= md;
        r /= 2;
    }
    return l;
}

ll d[1000001];

void update(int h,int l,int r,int x,int k)
{
    if (l==r)
    {
        d[h]=k;
        return;
    }
    int w=(l+r)/2;
    if (x<=w) update(h*2,l,w,x,k); else update(h*2+1,w+1,r,x,k);
    d[h]=(d[h*2]+d[h*2+1])%MOD;
}

ll get(int h,int l,int r,int x,int y)
{
    if (x>y) return 0;
    if (l==x && y==r) return d[h];
    int w=(l+r)/2;
    return (get(h*2,l,w,x,min(y,w))+get(h*2+1,w+1,r,max(x,w+1),y))%MOD;
}

void solve()
{
    cin >> n;
    for (ll i = 1; i <= n; i++)
    {
        a[i]=min(i-1,n-i);
    }
    ll sm0=1, sm1=0;
    for (int i = 1; i <= n; i++)
    {
        if (i%2)
        {
            dp[i]=sm0;
            sm1=(sm1+dp[i])%MOD;
        }else
        if (i%2==0)
        {
            dp[i]=sm1;
            sm0=(sm0+dp[i])%MOD;
        }
    }
    ll p=dp[n], o=binpow(2, n, MOD);
    o=binpow(o, MOD-2, MOD);
    cout << (p*o)%MOD << "\n";
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("capitals.in","r",stdin);
    //freopen("capitals.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll t=1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}
/*

10
4 1 7 6 5 5 4 2 3 1
*/


#include <bits/stdc++.h>
#include <random>
#include <ctime>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx2")
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define pii pair<int,int>
#define sqr(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define do_anal exit(0)

using namespace std;
//using namespace __gnu_pbds;

const ll MOD = 998244353;
const ll md = 11234549;
const ld PI = acosl(-1.0);
const ld E = 1e-15;
mt19937_64 rnd(time(0));
ll p1 = 227, p2 = 29 + rnd() % 100, md1 = MOD, md2 = MOD - rnd() % 1000;

//using ord_set=tree<T,null_type,less<T>,,tree_order_statistics_node_update>;

ll n, m, k, T, a[1000001];
bool tt[1001];

ll binpow(ll h, ll r, ll md)
{
    ll l = 1;
    while (r)
    {
        if (r & 1) l*=h, l%=md;
        h*=h;
        h%=md;
        r /= 2;
    }
    return l;
}

void solve()
{
    //cout << "----\n";
    cin >> n;
    vector<pll> v;
    ll x;
    for (int i = 2; i <= n; i++)
    {
        cout << "XOR 1 " << i << "\n";
        cin >> x;
        fflush(stdout);
        v.pb(mp(x, i));
    }
    sort(all(v));
    if (v[0].fi==0)
    {
        cout << "AND 1 " << v[0].se << "\n";
        cin >> x;
        cout << "! ";
        for (int i = 0; i < v.size(); i++) a[v[i].se]=v[i].fi^x;
        a[1]=x;
        for (int i = 1; i <= n; i++) cout << a[i] << " ";
        cout << "\n";
        return;
    }
    ll p=0;
    for (int i = 0; i < v.size()-1; i++)
        if (v[i].fi==v[i+1].fi)
        {
            cout << "AND " << v[i].se << " " << v[i+1].se << "\n";
            cin >> x;
            x=x^v[i].fi;
            fflush(stdout);
            cout << "! ";
            for (int i = 0; i < v.size(); i++) a[v[i].se]=v[i].fi^x;
            a[1]=x;
            for (int i = 1; i <= n; i++) cout << a[i] << " ";
            cout << "\n";
            return;
        }
    for (int i = 0; i < v.size()-1; i++)
        if (v[i].fi+1==v[i+1].fi && v[i].fi%2==0)
        {
            cout << "AND " << v[i].se << " " << v[i+1].se << "\n";
            cin >> x;
            x^=v[i].fi;
            fflush(stdout);
            cout << "AND 1 " << v[i].se << "\n";
            ll p;
            cin >> p;
            fflush(stdout);
            if (p%2) x++;
            cout << "! ";
            for (int i = 0; i < v.size(); i++) a[v[i].se]=v[i].fi^x;
            a[1]=x;
            for (int i = 1; i <= n; i++) cout << a[i] << " ";
            cout << "\n";
            return;
        }
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("d.in","r",stdin);
    //freopen("d.out","w",stdout);
    //ios::sync_with_stdio(0);
    //cin.tie(0);
    ll t=1;
    //cin >> t;
    T=t;
    while (t--)
    {
        solve();
    }
    return 0;
}

/*
5
4
4 4
1 1
2 2
3 3
4
4 4
4 1
1 4
2 2
6
3 2
2 1
1 2
3 3
3 4
3 1
5
1 1
1 2
1 3
1 4
5 5
4
1000000000 1000000000
1000000000 1
2 2
1000000000 999999999

1
4
1 1
2 1
33 3
2 2
*/


#include <bits/stdc++.h>
#include <random>
#include <ctime>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx2")
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define pii pair<int,int>
#define sqr(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define do_anal exit(0)

using namespace std;
//using namespace __gnu_pbds;

const ll MOD = 998244353;
const ll md = 11234549;
const ld PI = acosl(-1.0);
const ld E = 1e-15;
mt19937_64 rnd(time(0));
ll p1 = 227, p2 = 29 + rnd() % 100, md1 = MOD, md2 = MOD - rnd() % 1000;

//using ord_set=tree<T,null_type,less<T>,,tree_order_statistics_node_update>;

ll n, m, k, T, a[1000001];
bool tt[1001];

ll binpow(ll h, ll r, ll md)
{
    ll l = 1;
    while (r)
    {
        if (r & 1) l*=h, l%=md;
        h*=h;
        h%=md;
        r /= 2;
    }
    return l;
}

void solve()
{
    //cout << "----\n";
    cin >> n;
    vector<pll> v;
    ll x;
    for (int i = 2; i <= n; i++)
    {
        cout << "XOR 1 " << i << "\n";
        cin >> x;
        fflush(stdout);
        v.pb(mp(x, i));
    }
    sort(all(v));
    if (v[0].fi==0)
    {
        cout << "AND 1 " << v[0].se << "\n";
        cin >> x;
        cout << "! ";
        for (int i = 0; i < v.size(); i++) a[v[i].se]=v[i].fi^x;
        a[1]=x;
        for (int i = 1; i <= n; i++) cout << a[i] << " ";
        cout << "\n";
        return;
    }
    ll p=0;
    for (int i = 0; i < v.size()-1; i++)
        if (v[i].fi==v[i+1].fi)
        {
            cout << "AND " << v[i].se << " " << v[i+1].se << "\n";
            cin >> x;
            x=x^v[i].fi;
            fflush(stdout);
            cout << "! ";
            for (int i = 0; i < v.size(); i++) a[v[i].se]=v[i].fi^x;
            a[1]=x;
            for (int i = 1; i <= n; i++) cout << a[i] << " ";
            cout << "\n";
            return;
        }
    for (int i = 0; i < v.size()-1; i++)
        if (v[i].fi+1==v[i+1].fi)
        {
            cout << "AND " << v[i].se << " " << v[i+1].se << "\n";
            cin >> x;
            x^=v[i].fi;
            fflush(stdout);
            cout << "AND 1 " << v[i].se << "\n";
            ll p;
            cin >> p;
            fflush(stdout);
            if (p%2) x++;
            cout << "! ";
            for (int i = 0; i < v.size(); i++) a[v[i].se]=v[i].fi^x;
            a[1]=x;
            for (int i = 1; i <= n; i++) cout << a[i] << " ";
            cout << "\n";
            return;
        }
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("d.in","r",stdin);
    //freopen("d.out","w",stdout);
    //ios::sync_with_stdio(0);
    //cin.tie(0);
    ll t=1;
    //cin >> t;
    T=t;
    while (t--)
    {
        solve();
    }
    return 0;
}

/*
5
4
4 4
1 1
2 2
3 3
4
4 4
4 1
1 4
2 2
6
3 2
2 1
1 2
3 3
3 4
3 1
5
1 1
1 2
1 3
1 4
5 5
4
1000000000 1000000000
1000000000 1
2 2
1000000000 999999999

1
4
1 1
2 1
33 3
2 2
*/


#include <bits/stdc++.h>

#define int long long
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
const int N = (1<<16)+1;

int ans[N],sum[N];

int query(int key,int x,int y){
    int tmp;
    if(key==1) cout<<"AND "<<x<<" "<<y<<"\n";
    if(key==2) cout<<"OR "<<x<<" "<<y<<"\n";
    if(key==3) cout<<"XOR "<<x<<" "<<y<<"\n";
    cout.flush();
    cin>>tmp;
    return tmp;
}

void solve() {
    int n,id=0;
    cin>>n;
    sum[0]=1;
    for(int i=2;i<=n;i++){
        int a=query(3,1,i);
        ans[i]=a;
        if(!sum[a]) sum[a]=i;
        else id=i;
    }
    if(id){
        int res = query(1, sum[ans[id]], id);
        ans[1]=ans[id]^res;
        for(int i=2;i<=n;i++) ans[i]^=ans[i];
    } else{
        int k1=sum[1],k2=sum[2];
        int a1=query(1,k1,1);
        int a2=query(1,k2,1);
        int res=a1+a2%2;
        for(int i=1;i<=n;i++) ans[i]^=res;
    }
    cout<<"! ";
    for(int i=1;i<=n;i++) cout<<ans[i]<<" ";
}

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int _ = 1;
    cin >> _;
    while (_--)
        solve();
    return 0;
}


#include <bits/stdc++.h>

#define int long long
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
const int N = (1<<16)+1;

int ans[N],sum[N];

int query(int key,int x,int y){
    int tmp;
    if(key==1) cout<<"AND "<<x<<" "<<y<<"\n";
    if(key==2) cout<<"OR "<<x<<" "<<y<<"\n";
    if(key==3) cout<<"XOR "<<x<<" "<<y<<"\n";
    cout.flush();
    cin>>tmp;
    return tmp;
}

void solve() {
    int n,id=0;
    cin>>n;
    sum[0]=1;
    for(int i=2;i<=n;i++){
        int a=query(3,1,i);
        ans[i]=a;
        if(!sum[a]) sum[a]=i;
        else id=i;
    }
    if(id){
        int res = query(1, sum[ans[id]], id);
        ans[1]=ans[id]^res;
        for(int i=2;i<=n;i++) ans[i]^=ans[1];
    } else{
        int k1=sum[1],k2=sum[2];
        int a1=query(1,k1,1);
        int a2=query(1,k2,1);
        int res=a1+a2%2;
        for(int i=1;i<=n;i++) ans[i]^=res;
    }
    cout<<"! ";
    for(int i=1;i<=n;i++) cout<<ans[i]<<" ";
}

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int _ = 1;
    //cin >> _;
    while (_--)
        solve();
    return 0;
}


#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#define ll	long long
#define pii	pair<int,int>
#define pll pair<ll, ll>
#define LINF 0x7fffffffffffffff
#define INF 0x7fffffff
using namespace std;

ll N, M, DIGIT, ans, temp;
vector<ll> val1(16, -1);
vector<ll> m;

void cntDIGIT(ll num) {
	while (num) {
		DIGIT++;
		num /= 2;
	}
	DIGIT--;
}

ll cnt0(ll num) {
	ll ret = DIGIT;
	while (num) {
		ret -= (num % 2);
		num /= 2;
	}
	return ret;
}

ll cnt1(ll num) {
	ll ret = 0;
	while (num) {
		ret += (num % 2);
		num /= 2;
	}
	return ret;
}

ll findMax0() {
	ll maxi0_idx, maxi0 = -1;
	for (ll i = 2; i <= N; i++) {
		if (maxi0 < cnt0(m[i])) {
			maxi0 = cnt0(m[i]);
			maxi0_idx = i;
		}
	}
	return maxi0_idx;
}

ll mem[1 << 16][2];
vector<ll> findMax1() {
	vector<ll> ret;
	for (ll i = (1 << DIGIT) - 1; i >= 0; i--) {
		if (mem[i][1] != 0) {
			ret.push_back(mem[i][0]);
			ret.push_back(mem[i][1]);
			break;
		}

		for (ll mask = 1; mask < (1 << DIGIT); mask *= 2) {
			if ((i & mask) != 0) {
				ll target = (i ^ mask);
				if (mem[target][0] == 0) {
					mem[target][0] = mem[i][0];
				}
				else {
					mem[target][1] = mem[i][0];
				}
			}
		}
	}
	return ret;
}

vector<ll> Phase2() {
	vector<ll> ret;

	for (ll i = 2; i <= N; i++) {
		ll isFail = 0;
		for (ll d = 0; d < DIGIT; d++) {
			ll mask = 1 << d;
			if (val1[d] == -1 && ((~m[i]) & mask) == 0) {
				isFail = 1;
				break;
			}
		}
		if (isFail == 0) {
			ret.push_back(i);
			break;
		}
	}

	if (ret.size() == 0) {
		for (ll i = 2; i <= N; i++) {
			ll isFail = 0;
			for (ll d = 0; d < DIGIT; d++) {
				ll mask = 1 << d;
				if (val1[d] == -1 && (m[i] & mask) == 0) {
					isFail = 1;
					break;
				}
			}
			if (isFail == 0) {
				ret.push_back(i);
				if (ret.size() == 2) {
					break;
				}
			}
		}
	}

	return ret;
}

int main(void) {
	//ios::sync_with_stdio(false);
	//cin.tie(NULL), cout.tie(NULL);
	cin >> N;
	cntDIGIT(N);
	m.resize(N + 1);
	for (ll i = 2; i <= N; i++) {
		cout << "XOR 1 " << i << '\n';
		cin >> temp;
		m[i] = temp;
		if (mem[temp][0] == 0) {
			mem[temp][0] = i;
		}
		else {
			mem[temp][1] = i;
		}
	}

	ll max0Candi = findMax0();
	vector<ll> max1Candi = findMax1();
	ll max1Cnt = -1;
	if (max1Candi.size() >= 2) {
		cnt1(m[max1Candi[0]] & m[max1Candi[1]]);
	}
	ll max0Cnt = cnt0(m[max0Candi]);

	if (max0Cnt >= max1Cnt) {
		cout << "AND 1 " << max0Candi << '\n';
		ll valAND;
		cin >> valAND;
		ll valXOR = m[max0Candi];
		for (ll i = 0; i < DIGIT; i++) {
			ll mask = 1 << i;
			if ((valXOR & mask) == 0) {
				if ((valAND & mask) != 0) {
					val1[i] = 1;
				}
				else {
					val1[i] = 0;
				}
			}
		}
	}
	else {
		ll target1 = m[max1Candi[0]] ^ m[max1Candi[1]]; target1 = ~target1;
		cout << "AND " << max1Candi[0] << ' ' << max1Candi[1] << '\n';
		ll valAND;
		cin >> valAND;
		for (ll i = 0; i < DIGIT; i++) {
			ll mask = 1 << i;
			if ((target1 ^ mask) != 0) {
				if ((valAND & mask) != 0) {
					val1[i] = 0;
				}
				else {
					val1[i] = 1;
				}
			}
		}
	}

	// for(ll i = DIGIT - 1; i >= 0; i--) {
	//     cout << val1[i] << ' ';
	// }
	// cout << '\n';

	vector<ll> phase2 = Phase2();
	if (phase2.size() == 1) {
		cout << "AND 1 " << phase2[0] << '\n';
		ll valAND;
		cin >> valAND;
		ll valXOR = m[phase2[0]];
		for (ll i = 0; i < DIGIT; i++) {
			ll mask = 1 << i;
			if ((valXOR & mask) == 0) {
				if ((valAND & mask) != 0) {
					val1[i] = 1;
				}
				else {
					val1[i] = 0;
				}
			}
		}
	}
	else {
		cout << "AND " << phase2[0] << ' ' << phase2[1] << '\n';
		ll valAND;
		cin >> valAND;
		ll target1 = m[phase2[0]] ^ m[phase2[1]]; target1 = ~target1;
		for (ll i = 0; i < DIGIT; i++) {
			ll mask = 1 << i;
			if ((target1 & mask) != 0) {
				if ((valAND & mask) != 0) {
					if ((m[phase2[0]] & mask) == 0) {
						val1[i] = 1;
					}
					else {
						val1[i] = 0;
					}
				}
				else {
					if ((m[phase2[0]] & mask) == 0) {
						val1[i] = 0;
					}
					else {
						val1[i] = 1;
					}
				}
			}
		}
	}

	ll firstVal = 0, mulVal = 1;
	for (ll i = 0; i < DIGIT; i++) {
		firstVal += val1[i] * mulVal;
		mulVal *= 2;
	}

	cout << "! " << firstVal << ' ';
	for (ll i = 2; i <= N; i++) {
		ll val = 0, mulVal = 1;
		for (ll j = 0; j < DIGIT; j++) {
			ll mask = 1 << j;
			if ((mask & m[i]) == 0) {
				val += firstVal & mask;
			}
			else {
				val += ((~firstVal) & mask);
			}
			mulVal *= 2;
		}
		cout << val << ' ';
	}
	cout << '\n';

	return 0;
}


#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#define ll	long long
#define pii	pair<int,int>
#define pll pair<ll, ll>
#define LINF 0x7fffffffffffffff
#define INF 0x7fffffff
using namespace std;

ll N, M, DIGIT, ans, temp;
vector<ll> val1(16, -1);
vector<ll> m;

void cntDIGIT(ll num) {
	while (num) {
		DIGIT++;
		num /= 2;
	}
	DIGIT--;
}

ll cnt0(ll num) {
	ll ret = DIGIT;
	while (num) {
		ret -= (num % 2);
		num /= 2;
	}
	return ret;
}

ll cnt1(ll num) {
	ll ret = 0;
	while (num) {
		ret += (num % 2);
		num /= 2;
	}
	return ret;
}

ll findMax0() {
	ll maxi0_idx, maxi0 = -1;
	for (ll i = 2; i <= N; i++) {
		if (maxi0 < cnt0(m[i])) {
			maxi0 = cnt0(m[i]);
			maxi0_idx = i;
		}
	}
	return maxi0_idx;
}

ll mem[1 << 16][2];
vector<ll> findMax1() {
	vector<ll> ret;
	for (ll i = (1 << DIGIT) - 1; i >= 0; i--) {
		if (mem[i][1] != 0) {
			ret.push_back(mem[i][0]);
			ret.push_back(mem[i][1]);
			break;
		}

		for (ll mask = 1; mask < (1 << DIGIT); mask *= 2) {
			if ((i & mask) != 0) {
				ll target = (i ^ mask);
				if (mem[target][0] == 0) {
					mem[target][0] = mem[i][0];
				}
				else {
					mem[target][1] = mem[i][0];
				}
			}
		}
	}
	return ret;
}

vector<ll> Phase2() {
	vector<ll> ret;

	for (ll i = 2; i <= N; i++) {
		ll isFail = 0;
		for (ll d = 0; d < DIGIT; d++) {
			ll mask = 1 << d;
			if (val1[d] == -1 && ((~m[i]) & mask) == 0) {
				isFail = 1;
				break;
			}
		}
		if (isFail == 0) {
			ret.push_back(i);
			break;
		}
	}

	if (ret.size() == 0) {
		for (ll i = 2; i <= N; i++) {
			ll isFail = 0;
			for (ll d = 0; d < DIGIT; d++) {
				ll mask = 1 << d;
				if (val1[d] == -1 && (m[i] & mask) == 0) {
					isFail = 1;
					break;
				}
			}
			if (isFail == 0) {
				ret.push_back(i);
				if (ret.size() == 2) {
					break;
				}
			}
		}
	}

	return ret;
}

int main(void) {
	//ios::sync_with_stdio(false);
	//cin.tie(NULL), cout.tie(NULL);
	cin >> N;
	cntDIGIT(N);
	m.resize(N + 1);
	for (ll i = 2; i <= N; i++) {
		cout << "XOR 1 " << i << '\n';
		cin >> temp;
		m[i] = temp;
		if (mem[temp][0] == 0) {
			mem[temp][0] = i;
		}
		else {
			mem[temp][1] = i;
		}
	}

	ll max0Candi = findMax0();
	vector<ll> max1Candi = findMax1();
	ll max1Cnt = -1;
	if (max1Candi.size() >= 2) {
		cnt1(m[max1Candi[0]] & m[max1Candi[1]]);
	}
	ll max0Cnt = cnt0(m[max0Candi]);

	if (max0Cnt >= max1Cnt) {
		cout << "AND 1 " << max0Candi << '\n';
		ll valAND;
		cin >> valAND;
		ll valXOR = m[max0Candi];
		for (ll i = 0; i < DIGIT; i++) {
			ll mask = 1 << i;
			if ((valXOR & mask) == 0) {
				if ((valAND & mask) != 0) {
					val1[i] = 1;
				}
				else {
					val1[i] = 0;
				}
			}
		}
	}
	else {
		ll target1 = m[max1Candi[0]] ^ m[max1Candi[1]]; target1 = ~target1;
		cout << "AND " << max1Candi[0] << ' ' << max1Candi[1] << '\n';
		ll valAND;
		cin >> valAND;
		for (ll i = 0; i < DIGIT; i++) {
			ll mask = 1 << i;
			if ((target1 ^ mask) != 0) {
				if ((valAND & mask) != 0) {
					val1[i] = 0;
				}
				else {
					val1[i] = 1;
				}
			}
		}
	}

	// for(ll i = DIGIT - 1; i >= 0; i--) {
	//     cout << val1[i] << ' ';
	// }
	// cout << '\n';

	vector<ll> phase2 = Phase2();
	if (phase2.size() == 1) {
		cout << "AND 1 " << phase2[0] << '\n';
		ll valAND;
		cin >> valAND;
		ll valXOR = m[phase2[0]];
		for (ll i = 0; i < DIGIT; i++) {
			ll mask = 1 << i;
			if ((valXOR & mask) == 0) {
				if ((valAND & mask) != 0) {
					val1[i] = 1;
				}
				else {
					val1[i] = 0;
				}
			}
		}
	}
	else {
		cout << "AND " << phase2[0] << ' ' << phase2[1] << '\n';
		ll valAND;
		cin >> valAND;
		ll target1 = m[phase2[0]] ^ m[phase2[1]]; target1 = ~target1;
		for (ll i = 0; i < DIGIT; i++) {
			ll mask = 1 << i;
			if ((target1 ^ mask) != 0) {
				if ((valAND & mask) != 0) {
					if ((m[phase2[0]] & mask) == 0) {
						val1[i] = 1;
					}
					else {
						val1[i] = 0;
					}
				}
				else {
					if ((m[phase2[0]] & mask) == 0) {
						val1[i] = 0;
					}
					else {
						val1[i] = 1;
					}
				}
			}
		}
	}

	ll firstVal = 0, mulVal = 1;
	for (ll i = 0; i < DIGIT; i++) {
		firstVal += val1[i] * mulVal;
		mulVal *= 2;
	}

	cout << "! " << firstVal << ' ';
	for (ll i = 2; i <= N; i++) {
		ll val = 0, mulVal = 1;
		for (ll j = 0; j < DIGIT; j++) {
			ll mask = 1 << j;
			if ((mask & m[i]) == 0) {
				val += firstVal & mask;
			}
			else {
				val += ((~firstVal) & mask);
			}
			mulVal *= 2;
		}
		cout << val << ' ';
	}
	cout << '\n';

	return 0;
}


#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#define ll	long long
#define pii	pair<int,int>
#define pll pair<ll, ll>
#define LINF 0x7fffffffffffffff
#define INF 0x7fffffff
using namespace std;

ll N, M, DIGIT, ans, temp;
vector<ll> val1(16, -1);
vector<ll> m;

void cntDIGIT(ll num) {
	while (num) {
		DIGIT++;
		num /= 2;
	}
	DIGIT--;
}

ll cnt0(ll num) {
	ll ret = DIGIT;
	while (num) {
		ret -= (num % 2);
		num /= 2;
	}
	return ret;
}

ll cnt1(ll num) {
	ll ret = 0;
	while (num) {
		ret += (num % 2);
		num /= 2;
	}
	return ret;
}

ll findMax0() {
	ll maxi0_idx, maxi0 = -1;
	for (ll i = 2; i <= N; i++) {
		if (maxi0 < cnt0(m[i])) {
			maxi0 = cnt0(m[i]);
			maxi0_idx = i;
		}
	}
	return maxi0_idx;
}

ll mem[1 << 16][2];
vector<ll> findMax1() {
	vector<ll> ret;
	for (ll i = (1 << DIGIT) - 1; i >= 0; i--) {
		if (mem[i][1] != 0) {
			ret.push_back(mem[i][0]);
			ret.push_back(mem[i][1]);
			break;
		}

		for (ll mask = 1; mask < (1 << DIGIT); mask *= 2) {
			if ((i & mask) != 0) {
				ll target = (i ^ mask);
				if (mem[target][0] == 0) {
					mem[target][0] = mem[i][0];
				}
				else {
					mem[target][1] = mem[i][0];
				}
			}
		}
	}
	return ret;
}

vector<ll> Phase2() {
	vector<ll> ret;

	for (ll i = 2; i <= N; i++) {
		ll isFail = 0;
		for (ll d = 0; d < DIGIT; d++) {
			ll mask = 1 << d;
			if (val1[d] == -1 && ((~m[i]) & mask) == 0) {
				isFail = 1;
				break;
			}
		}
		if (isFail == 0) {
			ret.push_back(i);
			break;
		}
	}

	if (ret.size() == 0) {
		for (ll i = 2; i <= N; i++) {
			ll isFail = 0;
			for (ll d = 0; d < DIGIT; d++) {
				ll mask = 1 << d;
				if (val1[d] == -1 && (m[i] & mask) == 0) {
					isFail = 1;
					break;
				}
			}
			if (isFail == 0) {
				ret.push_back(i);
				if (ret.size() == 2) {
					break;
				}
			}
		}
	}

	return ret;
}

int main(void) {
	//ios::sync_with_stdio(false);
	//cin.tie(NULL), cout.tie(NULL);
	cin >> N;
	cntDIGIT(N);
	m.resize(N + 1);
	for (ll i = 2; i <= N; i++) {
		cout << "XOR 1 " << i << '\n';
		cin >> temp;
		m[i] = temp;
		if (mem[temp][0] == 0) {
			mem[temp][0] = i;
		}
		else {
			mem[temp][1] = i;
		}
	}

	ll max0Candi = findMax0();
	vector<ll> max1Candi = findMax1();
	ll max1Cnt = -1;
	if (max1Candi.size() >= 2) {
		cnt1(m[max1Candi[0]] & m[max1Candi[1]]);
	}
	ll max0Cnt = cnt0(m[max0Candi]);

	if (max0Cnt >= max1Cnt) {
		cout << "AND 1 " << max0Candi << '\n';
		ll valAND;
		cin >> valAND;
		ll valXOR = m[max0Candi];
		for (ll i = 0; i < DIGIT; i++) {
			ll mask = 1 << i;
			if ((valXOR & mask) == 0) {
				if ((valAND & mask) != 0) {
					val1[i] = 1;
				}
				else {
					val1[i] = 0;
				}
			}
		}
	}
	else {
		ll target1 = m[max1Candi[0]] ^ m[max1Candi[1]]; target1 = ~target1;
		cout << "AND " << max1Candi[0] << ' ' << max1Candi[1] << '\n';
		ll valAND;
		cin >> valAND;
		for (ll i = 0; i < DIGIT; i++) {
			ll mask = 1 << i;
			if ((target1 ^ mask) != 0) {
				if ((valAND & mask) != 0) {
					val1[i] = 0;
				}
				else {
					val1[i] = 1;
				}
			}
		}
	}

	// for(ll i = DIGIT - 1; i >= 0; i--) {
	//     cout << val1[i] << ' ';
	// }
	// cout << '\n';

	vector<ll> phase2 = Phase2();
	if (phase2.size() == 1) {
		cout << "AND 1 " << phase2[0] << '\n';
		ll valAND;
		cin >> valAND;
		ll valXOR = m[phase2[0]];
		for (ll i = 0; i < DIGIT; i++) {
			ll mask = 1 << i;
			if ((valXOR & mask) == 0) {
				if ((valAND & mask) != 0) {
					val1[i] = 1;
				}
				else {
					val1[i] = 0;
				}
			}
		}
	}
	else {
		cout << "AND " << phase2[0] << ' ' << phase2[1] << '\n';
		ll valAND;
		cin >> valAND;
		ll target1 = m[phase2[0]] ^ m[phase2[1]]; target1 = ~target1;
		for (ll i = 0; i < DIGIT; i++) {
			ll mask = 1 << i;
			if ((target1 ^ mask) != 0) {
				if ((valAND & mask) != 0) {
					val1[i] = 0;
				}
				else {
					val1[i] = 1;
				}
			}
		}
	}

	ll firstVal = 0, mulVal = 1;
	for (ll i = 0; i < DIGIT; i++) {
		firstVal += val1[i] * mulVal;
		mulVal *= 2;
	}

	cout << "! " << firstVal << ' ';
	for (ll i = 2; i <= N; i++) {
		ll val = 0, mulVal = 1;
		for (ll j = 0; j < DIGIT; j++) {
			ll mask = 1 << j;
			if ((mask & m[i]) == 0) {
				val += firstVal & mask;
			}
			else {
				val += ((~firstVal) & mask);
			}
			mulVal *= 2;
		}
		cout << val << ' ';
	}
	cout << '\n';

	return 0;
}


#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#define ll	long long
#define pii	pair<int,int>
#define pll pair<ll, ll>
#define LINF 0x7fffffffffffffff
#define INF 0x7fffffff
using namespace std;

ll N, M, DIGIT, ans, temp;
vector<ll> val1(16, -1);
vector<ll> m;

void cntDIGIT(ll num) {
	while (num) {
		DIGIT++;
		num /= 2;
	}
	DIGIT--;
}

ll cnt0(ll num) {
	ll ret = DIGIT;
	while (num) {
		ret -= (num % 2);
		num /= 2;
	}
	return ret;
}

ll cnt1(ll num) {
	ll ret = 0;
	while (num) {
		ret += (num % 2);
		num /= 2;
	}
	return ret;
}

ll findMax0() {
	ll maxi0_idx, maxi0 = -1;
	for (ll i = 2; i <= N; i++) {
		if (maxi0 < cnt0(m[i])) {
			maxi0 = cnt0(m[i]);
			maxi0_idx = i;
		}
	}
	return maxi0_idx;
}

ll mem[1 << 16][2];
vector<ll> findMax1() {
	vector<ll> ret;
	for (ll i = (1 << DIGIT) - 1; i >= 0; i--) {
		if (mem[i][1] != 0) {
			ret.push_back(mem[i][0]);
			ret.push_back(mem[i][1]);
			break;
		}

		for (ll mask = 1; mask < (1 << DIGIT); mask *= 2) {
			if ((i & mask) != 0) {
				ll target = (i ^ mask);
				if (mem[target][0] == 0) {
					mem[target][0] = mem[i][0];
				}
				else {
					mem[target][1] = mem[i][0];
				}
			}
		}
	}
	return ret;
}

vector<ll> Phase2() {
	vector<ll> ret;

	for (ll i = 2; i <= N; i++) {
		ll isFail = 0;
		for (ll d = 0; d < DIGIT; d++) {
			ll mask = 1 << d;
			if (val1[d] == -1 && ((~m[i]) & mask) == 0) {
				isFail = 1;
				break;
			}
		}
		if (isFail == 0) {
			ret.push_back(i);
			break;
		}
	}

	if (ret.size() == 0) {
		for (ll i = 2; i <= N; i++) {
			ll isFail = 0;
			for (ll d = 0; d < DIGIT; d++) {
				ll mask = 1 << d;
				if (val1[d] == -1 && (m[i] & mask) == 0) {
					isFail = 1;
					break;
				}
			}
			if (isFail == 0) {
				ret.push_back(i);
				if (ret.size() == 2) {
					break;
				}
			}
		}
	}

	return ret;
}

int main(void) {
	//ios::sync_with_stdio(false);
	//cin.tie(NULL), cout.tie(NULL);
	cin >> N;
	cntDIGIT(N);
	m.resize(N + 1);
	for (ll i = 2; i <= N; i++) {
		cout << "XOR 1 " << i << '\n';
		cin >> temp;
		m[i] = temp;
		if (mem[temp][0] == 0) {
			mem[temp][0] = i;
		}
		else {
			mem[temp][1] = i;
		}
	}

	ll max0Candi = findMax0();
	vector<ll> max1Candi = findMax1();
	ll max1Cnt = -1;
	if (max1Candi.size() >= 2) {
		cnt1(m[max1Candi[0]] & m[max1Candi[1]]);
	}
	ll max0Cnt = cnt0(m[max0Candi]);

	if (max0Cnt >= max1Cnt) {
		cout << "AND 1 " << max0Candi << '\n';
		ll valAND;
		cin >> valAND;
		ll valXOR = m[max0Candi];
		for (ll i = 0; i < DIGIT; i++) {
			ll mask = 1 << i;
			if ((valXOR & mask) == 0) {
				if ((valAND & mask) == 1) {
					val1[i] = 1;
				}
				else {
					val1[i] = 0;
				}
			}
		}
	}
	else {
		ll target1 = m[max1Candi[0]] ^ m[max1Candi[1]]; target1 = ~target1;
		cout << "AND " << max1Candi[0] << ' ' << max1Candi[1] << '\n';
		ll valAND;
		cin >> valAND;
		for (ll i = 0; i < DIGIT; i++) {
			ll mask = 1 << i;
			if ((target1 ^ mask) != 0) {
				if ((valAND & mask) == 1) {
					val1[i] = 0;
				}
				else {
					val1[i] = 1;
				}
			}
		}
	}

	// for(ll i = DIGIT - 1; i >= 0; i--) {
	//     cout << val1[i] << ' ';
	// }
	// cout << '\n';

	vector<ll> phase2 = Phase2();
	if (phase2.size() == 1) {
		cout << "AND 1 " << phase2[0] << '\n';
		ll valAND;
		cin >> valAND;
		ll valXOR = m[phase2[0]];
		for (ll i = 0; i < DIGIT; i++) {
			ll mask = 1 << i;
			if ((valXOR & mask) == 0) {
				if ((valAND & mask) == 1) {
					val1[i] = 1;
				}
				else {
					val1[i] = 0;
				}
			}
		}
	}
	else {
		cout << "AND " << phase2[0] << ' ' << phase2[1] << '\n';
		ll valAND;
		cin >> valAND;
		ll target1 = m[phase2[0]] ^ m[phase2[1]]; target1 = ~target1;
		for (ll i = 0; i < DIGIT; i++) {
			ll mask = 1 << i;
			if ((target1 ^ mask) != 0) {
				if ((valAND & mask) == 1) {
					val1[i] = 0;
				}
				else {
					val1[i] = 1;
				}
			}
		}
	}

	ll firstVal = 0, mulVal = 1;
	for (ll i = 0; i < DIGIT; i++) {
		firstVal += val1[i] * mulVal;
		mulVal *= 2;
	}

	cout << "! " << firstVal << ' ';
	for (ll i = 2; i <= N; i++) {
		ll val = 0, mulVal = 1;
		for (ll j = 0; j < DIGIT; j++) {
			ll mask = 1 << j;
			if ((mask & m[i]) == 0) {
				val += firstVal & mask;
			}
			else {
				val += ((~firstVal) & mask);
			}
			mulVal *= 2;
		}
		cout << val << ' ';
	}
	cout << '\n';

	return 0;
}


#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#define ll	long long
#define pii	pair<int,int>
#define pll pair<ll, ll>
#define LINF 0x7fffffffffffffff
#define INF 0x7fffffff
using namespace std;

ll N, M, DIGIT, ans, temp;
vector<ll> val1(16, -1);
vector<ll> m;

void cntDIGIT(ll num) {
	while (num) {
		DIGIT++;
		num /= 2;
	}
	DIGIT--;
}

ll cnt0(ll num) {
	ll ret = DIGIT;
	while (num) {
		ret -= (num % 2);
		num /= 2;
	}
	return ret;
}

ll cnt1(ll num) {
	ll ret = 0;
	while (num) {
		ret += (num % 2);
		num /= 2;
	}
	return ret;
}

ll findMax0() {
	ll maxi0_idx, maxi0 = -1;
	for (ll i = 2; i <= N; i++) {
		if (maxi0 < cnt0(m[i])) {
			maxi0 = cnt0(m[i]);
			maxi0_idx = i;
		}
	}
	return maxi0_idx;
}

ll mem[1 << 16][2];
vector<ll> findMax1() {
	vector<ll> ret;
	for (ll i = (1 << DIGIT) - 1; i >= 0; i--) {
		if (mem[i][1] != 0) {
			ret.push_back(mem[i][0]);
			ret.push_back(mem[i][1]);
			break;
		}

		for (ll mask = 1; mask < (1 << DIGIT); mask *= 2) {
			if ((i & mask) != 0) {
				ll target = (i ^ mask);
				if (mem[target][0] == 0) {
					mem[target][0] = mem[i][0];
				}
				else {
					mem[target][1] = mem[i][0];
				}
			}
		}
	}
	return ret;
}

vector<ll> Phase2() {
	vector<ll> ret;

	for (ll i = 2; i <= N; i++) {
		ll isFail = 0;
		for (ll d = 0; d < DIGIT; d++) {
			ll mask = 1 << d;
			if (val1[d] == -1 && ((~m[i]) & mask) == 0) {
				isFail = 1;
				break;
			}
		}
		if (isFail == 0) {
			ret.push_back(i);
			break;
		}
	}

	if (ret.size() == 0) {
		for (ll i = 2; i <= N; i++) {
			ll isFail = 0;
			for (ll d = 0; d < DIGIT; d++) {
				ll mask = 1 << d;
				if (val1[d] == -1 && (m[i] & mask) == 0) {
					isFail = 1;
					break;
				}
			}
			if (isFail == 0) {
				ret.push_back(i);
				if (ret.size() == 2) {
					break;
				}
			}
		}
	}

	return ret;
}

int main(void) {
	//ios::sync_with_stdio(false);
	//cin.tie(NULL), cout.tie(NULL);
	cin >> N;
	cntDIGIT(N);
	m.resize(N + 1);
	for (ll i = 2; i <= N; i++) {
		cout << "XOR 1 " << i << '\n';
		cin >> temp;
		m[i] = temp;
		if (mem[temp][0] == 0) {
			mem[temp][0] = i;
		}
		else {
			mem[temp][1] = i;
		}
	}

	ll max0Candi = findMax0();
	vector<ll> max1Candi = findMax1();
	ll max1Cnt = cnt1(m[max1Candi[0]] & m[max1Candi[1]]);
	ll max0Cnt = cnt0(m[max0Candi]);

	if (max0Cnt >= max1Cnt) {
		cout << "AND 1 " << max0Candi << '\n';
		ll valAND;
		cin >> valAND;
		ll valXOR = m[max0Candi];
		for (ll i = 0; i < DIGIT; i++) {
			ll mask = 1 << i;
			if ((valXOR & mask) == 0) {
				if ((valAND & mask) == 1) {
					val1[i] = 1;
				}
				else {
					val1[i] = 0;
				}
			}
		}
	}
	else {
		ll target1 = m[max1Candi[0]] ^ m[max1Candi[1]]; target1 = ~target1;
		cout << "AND " << max1Candi[0] << ' ' << max1Candi[1] << '\n';
		ll valAND;
		cin >> valAND;
		for (ll i = 0; i < DIGIT; i++) {
			ll mask = 1 << i;
			if ((target1 ^ mask) != 0) {
				if ((valAND & mask) == 1) {
					val1[i] = 0;
				}
				else {
					val1[i] = 1;
				}
			}
		}
	}

    // for(ll i = DIGIT - 1; i >= 0; i--) {
    //     cout << val1[i] << ' ';
    // }
    // cout << '\n';

	vector<ll> phase2 = Phase2();
	if (phase2.size() == 1) {
		cout << "AND 1 " << phase2[0] << '\n';
		ll valAND;
		cin >> valAND;
		ll valXOR = m[phase2[0]];
		for (ll i = 0; i < DIGIT; i++) {
			ll mask = 1 << i;
			if ((valXOR & mask) == 0) {
				if ((valAND & mask) == 1) {
					val1[i] = 1;
				}
				else {
					val1[i] = 0;
				}
			}
		}
	}
	else {
		cout << "AND " << phase2[0] << ' ' << phase2[1] << '\n';
		ll valAND;
		cin >> valAND;
		ll target1 = m[phase2[0]] ^ m[phase2[1]]; target1 = ~target1;
		for (ll i = 0; i < DIGIT; i++) {
			ll mask = 1 << i;
			if ((target1 ^ mask) != 0) {
				if ((valAND & mask) == 1) {
					val1[i] = 0;
				}
				else {
					val1[i] = 1;
				}
			}
		}
	}

	ll firstVal = 0, mulVal = 1;
	for (ll i = 0; i < DIGIT; i++) {
		firstVal += val1[i] * mulVal;
		mulVal *= 2;
	}

	cout << "! " << firstVal << ' ';
	for (ll i = 2; i <= N; i++) {
		ll val = 0, mulVal = 1;
		for (ll j = 0; j < DIGIT; j++) {
			ll mask = 1 << j;
			if ((mask & m[i]) == 0) {
				val += firstVal & mask;
			}
			else {
				val += ((~firstVal) & mask);
			}
			mulVal *= 2;
		}
		cout << val << ' ';
	}
	cout << '\n';

	return 0;
}


#include <math.h>
#include <string.h>
#include <iostream>
#include <fstream>
#include <map>
#include <algorithm>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <queue>

#define fi "599c.inp"
#define fo "599c.out"

using namespace std;

map<int,int>mm;
map<int,int>::reverse_iterator ite;

int n,pt;
int a[100005],luu[100005];

bool ss(int x, int y){
	if(x>y) return 1;
	return 0;
}

void solve(){

	int dem,i,xpl,l;
	pt=l=0;

	for(i=1;i<=n;i++){
		cin>>a[i];
		mm[a[i]]++;
	}

	xpl=1;
	pt = n;
	while(pt>0){

		ite = mm.rbegin();
		while(ite->second>0){

			luu[++l] = a[pt];
			mm[a[pt]]--;
			pt--;
		}
		if(ite->second==0){
			dem++;
			sort(luu+xpl,luu+l+1,ss);
			mm.erase(ite->first);
			xpl=l+1;
		}
	}

	for(i=1;i<=l;i++){
		if(luu[i]<luu[i+1]){
			cout<<1<<endl;
			return;
		}
	}
	cout<<dem<<endl;
}

int main(){

//	freopen(fi,"r",stdin);
//	freopen(fo,"w",stdout);

	while(cin>>n) solve();

	return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n, k=0, x=0, a[100005],b[100005];
	cin>>n;
	for(int i=0 ; i<n ; i++)
	{
		cin>>a[i];
		b[i] = a[i];
	}
	sort(b,b+n);
	for(int i=0 ; i<n ; i++)
	{
		k += a[i]-b[i];
		if(k == 0)
			x++;
	}
	cout<<x<<endl;
}


#include <math.h>
#include <string.h>
#include <iostream>
#include <fstream>
#include <map>
#include <algorithm>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <queue>

#define fi "599c.inp"
#define fo "599c.out"

using namespace std;

map<int,int>mm;
map<int,int>::reverse_iterator ite;

int n,pt;
int a[100005],b[100005];

void solve(){

	int i,aa,bb,da;
	da=aa=bb=0;

	for(i=1;i<=n;i++){
		cin>>a[i];
		b[i]=a[i];
	}
	sort(b+1,b+n+1);
	bb=1;
	aa=1;
	mm[a[1]]++;

	while(aa<=n && bb<=n){

		if(a[aa]!=b[bb]){
			mm[a[aa]]++;
			aa++;
		}else{
			ite = mm.rbegin();
			if(ite->first>b[bb])
			while(ite->second>0){
				bb++;
				if(b[bb]==ite->first) ite->second--;
			}

			aa++;
			bb++;
			da++;
		}

	}

	cout<<da<<endl;
}

int main(){

//	freopen(fi,"r",stdin);
//	freopen(fo,"w",stdout);

	while(cin>>n) solve();

	return 0;
}


#include <math.h>
#include <string.h>
#include <iostream>
#include <fstream>
#include <map>
#include <algorithm>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <queue>

#define fi "599c.inp"
#define fo "599c.out"

using namespace std;

map<int,int>mm;
map<int,int>::reverse_iterator ite;

int n,pt;
int a[100005],luu[100005];

bool ss(int x, int y){
	if(x>y) return 1;
	return 0;
}

void solve(){

	int i,so,l,r,minn,da,in;
	bool first;
	da=0;

	for(i=1;i<=n;i++) {
		cin>>a[i];
		mm[a[i]]++;
	}

	pt = n;
	l = 1;
	r = 0;
	minn=2e9;
	while(pt>0 && mm.size()>0){

		ite=mm.rbegin();
		so = ite->first;
		first = true;

		while(mm.count(so)>0){

			if(a[pt]!=so){

				first = false;
			}

			if(first) da++;

			in=--mm[a[pt]];
		//	if(pt==3){
		//		cout<<"ldfj";
		//	}
			minn=min(minn,a[pt]);
			luu[++r] = a[pt];
			if(in==0){
				mm.erase(a[pt]);
			}
			pt--;
		}

		if(mm.size()>0){

			ite = mm.rbegin();
			if(ite->first<=minn){

				if(!first)
					da++;
				sort(luu+l,luu+r+1,ss);
				l=r+1;
			}

		}else{
			if(r>l){
				sort(luu+l,luu+r+1,ss);
				da++;
			}
		}

	}

	for(i=1;i<r;i++){
		if(luu[i]<luu[i+1]){
			cout<<1<<endl;
			return;
		}
	}
	cout<<da<<endl;
}

int main(){

//	freopen(fi,"r",stdin);
//	freopen(fo,"w",stdout);

	while(cin>>n) solve();

	return 0;
}


#include <math.h>
#include <string.h>
#include <iostream>
#include <fstream>
#include <map>
#include <algorithm>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <queue>

#define fi "599c.inp"
#define fo "599c.out"

using namespace std;

map<int,int>mm;
map<int,int>::reverse_iterator ite;

int n,pt;
int a[100005],luu[100005];

bool ss(int x, int y){
	if(x>y) return 1;
	return 0;
}

void solve(){

	int dem,i,xpl,l;
	pt=l=dem=0;

	for(i=1;i<=n;i++){
		cin>>a[i];
		mm[a[i]]++;
	}

	xpl=1;
	pt = n;
	while(pt>0){

		ite = mm.rbegin();
		while(ite->second>0){

			luu[++l] = a[pt];
			mm[a[pt]]--;
			pt--;
		}
		if(ite->second==0){
			dem++;
			sort(luu+xpl,luu+l+1,ss);
			mm.erase(ite->first);
			xpl=l+1;
		}
	}

	for(i=1;i<=l;i++){
		if(luu[i]<luu[i+1]){
			cout<<1<<endl;
			return;
		}
	}
	cout<<dem<<endl;
}

int main(){

	//freopen(fi,"r",stdin);
	//freopen(fo,"w",stdout);

	while(cin>>n) solve();

	return 0;
}


#include <math.h>
#include <string.h>
#include <iostream>
#include <fstream>
#include <map>
#include <algorithm>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <queue>

#define fi "599c.inp"
#define fo "599c.out"

using namespace std;

map<int,int>mm;
map<int,int>::reverse_iterator ite;

int n,pt;
int a[100005],luu[100005];

bool ss(int x, int y){
	if(x>y) return 1;
	return 0;
}

void solve(){

	int dem,i,xpl,l;
	pt=l=dem=0;

	for(i=1;i<=n;i++){
		cin>>a[i];
		mm[a[i]]++;
	}

	xpl=1;
	pt = n;
	while(pt>0){

		ite = mm.rbegin();
		if(ite->second == 0){
			mm.erase(ite->first);
			continue;
		}
		bool first = true;
		while(ite->second>0){

			if(a[pt]!=ite->first){
				first = false;
			}

			if(first) dem++;

			luu[++l] = a[pt];
			mm[a[pt]]--;
			pt--;
		}
		if(ite->second==0){
			if(!first)
				dem++;
			sort(luu+xpl,luu+l+1,ss);
			mm.erase(ite->first);
			xpl=l+1;
		}
	}

	for(i=1;i<=l;i++){
		if(luu[i]<luu[i+1]){
			cout<<1<<endl;
			return;
		}
	}
	cout<<dem<<endl;
}

int main(){

//	freopen(fi,"r",stdin);
//	freopen(fo,"w",stdout);

	while(cin>>n) solve();

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector< ii > vii;

#define INF 0x3F3F3F3F
#define LINF 0x3F3F3F3F3F3F3F3FLL
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define LSONE(s) ((s)&(-s)) //LASTBIT
#define DEG_to_RAD(X)   (X * PI / 180)
#define F first
#define S second
#define PI 2*acos(0)

#ifdef ONLINE_JUDGE
#define debug(args...)
#else
#define debug(args...) fprintf(stderr,args)
#endif

//////////////////////
int dx[] = {1,-1,0,0};
int dy[] = {0,0,-1,1};
//////////////////////

void arquivo()
{
	freopen("","r",stdin);
	freopen("","w",stdout);
}

const int N = 100001;

ll v[N];
int n;
int tr[4*N];

int join( int a, int b ){
	if( a == -1 ) return b;
	if( b == -1 ) return a;
	if( v[a] < v[b] ) return a;
	else return b;
}

void build( int no, int l, int r ){
	if( l == r ){
		tr[no] = l;
		return;
	}
	int nxt = (no<<1), mid = (l+r)>>1;
	build(nxt,l,mid); build(nxt+1,mid+1,r);
	tr[no] = join(tr[nxt],tr[nxt+1]);
}

int query( int no, int l, int r, int i, int j ){
	if( r < i || l > j ) return -1;
	if( l >= i && r <= j ) return tr[no];
	int nxt = (no<<1), mid = (l+r)>>1;
	return join(query(nxt,l,mid,i,j),query(nxt+1,mid+1,r,i,j));
}

int tr2[4*N];

int join2( int a, int b ){
	if( a == -1 ) return b;
	if( b == -1 ) return a;
	if( v[a] >= v[b] ) return a;
	else return b;
}

void build2( int no, int l, int r ){
	if( l == r ){
		tr2[no] = l;
		return;
	}
	int nxt = (no<<1), mid = (l+r)>>1;
	build2(nxt,l,mid); build2(nxt+1,mid+1,r);
	tr2[no] = join2(tr2[nxt],tr2[nxt+1]);
}

int query2( int no, int l, int r, int i, int j ){
	if( r < i || l > j ) return -1;
	if( l >= i && r <= j ) return tr2[no];
	int nxt = (no<<1), mid = (l+r)>>1;
	return join2(query2(nxt,l,mid,i,j),query2(nxt+1,mid+1,r,i,j));
}

int main()
{
	//ios::sync_with_stdio(0);
	scanf("%d",&n);
	for(int i=0;i<n;++i){
		scanf("%lld",v+i);
	}
	build(1,0,n-1);
	build2(1,0,n-1);
	ll qtd = 0;

	int pos = 0;
	while( pos != n ){
		qtd++;
		int foo = query(1,0,n-1,pos,n-1);
		int q1 = query2(1,0,n-1,pos,foo);
		if( v[foo] == v[q1] ) qtd+=(foo-pos);
		pos = foo+1;
	}
	printf("%lld\n",qtd);

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector< ii > vii;

#define INF 0x3F3F3F3F
#define LINF 0x3F3F3F3F3F3F3F3FLL
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define LSONE(s) ((s)&(-s)) //LASTBIT
#define DEG_to_RAD(X)   (X * PI / 180)
#define F first
#define S second
#define PI 2*acos(0)

#ifdef ONLINE_JUDGE
#define debug(args...)
#else
#define debug(args...) fprintf(stderr,args)
#endif

//////////////////////
int dx[] = {1,-1,0,0};
int dy[] = {0,0,-1,1};
//////////////////////

void arquivo()
{
	freopen("","r",stdin);
	freopen("","w",stdout);
}

const int N = 100001;

ll v[N];
int n;
int tr[4*N];

int join( int a, int b ){
	if( a == -1 ) return b;
	if( b == -1 ) return a;
	if( v[a] < v[b] ) return a;
	else return b;
}

void build( int no, int l, int r ){
	if( l == r ){
		tr[no] = l;
		return;
	}
	int nxt = (no<<1), mid = (l+r)>>1;
	build(nxt,l,mid); build(nxt+1,mid+1,r);
	tr[no] = join(tr[nxt],tr[nxt+1]);
}

int query( int no, int l, int r, int i, int j ){
	if( r < i || l > j ) return -1;
	if( l >= i && r <= j ) return tr[no];
	int nxt = (no<<1), mid = (l+r)>>1;
	return join(query(nxt,l,mid,i,j),query(nxt+1,mid+1,r,i,j));
}

int tr2[4*N];

int join2( int a, int b ){
	if( a == -1 ) return b;
	if( b == -1 ) return a;
	if( v[a] >= v[b] ) return a;
	else return b;
}

void build2( int no, int l, int r ){
	if( l == r ){
		tr2[no] = l;
		return;
	}
	int nxt = (no<<1), mid = (l+r)>>1;
	build2(nxt,l,mid); build2(nxt+1,mid+1,r);
	tr2[no] = join2(tr2[nxt],tr2[nxt+1]);
}

int query2( int no, int l, int r, int i, int j ){
	if( r < i || l > j ) return -1;
	if( l >= i && r <= j ) return tr2[no];
	int nxt = (no<<1), mid = (l+r)>>1;
	return join2(query2(nxt,l,mid,i,j),query2(nxt+1,mid+1,r,i,j));
}

int main()
{
	//ios::sync_with_stdio(0);
	scanf("%d",&n);
	for(int i=0;i<n;++i){
		scanf("%lld",v+i);
	}
	build(1,0,n-1);
	build2(1,0,n-1);
	ll qtd = 0;
	int pos = 0;
	while( pos != n ){
		qtd++;
		int foo = query(1,0,n-1,pos,n-1);
		while( v[pos] == v[foo] && pos < foo ){
			qtd++;
			pos++;
		}
		pos = foo+1;
	}
	printf("%lld\n",qtd);

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector< ii > vii;

#define INF 0x3F3F3F3F
#define LINF 0x3F3F3F3F3F3F3F3FLL
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define LSONE(s) ((s)&(-s)) //LASTBIT
#define DEG_to_RAD(X)   (X * PI / 180)
#define F first
#define S second
#define PI 2*acos(0)

#ifdef ONLINE_JUDGE
#define debug(args...)
#else
#define debug(args...) fprintf(stderr,args)
#endif

//////////////////////
int dx[] = {1,-1,0,0};
int dy[] = {0,0,-1,1};
//////////////////////

void arquivo()
{
	freopen("","r",stdin);
	freopen("","w",stdout);
}

const int N = 100001;

ll v[N];
int n;
int tr[4*N];

int join( int a, int b ){
	if( a == -1 ) return b;
	if( b == -1 ) return a;
	if( v[a] < v[b] ) return a;
	else return b;
}

void build( int no, int l, int r ){
	if( l == r ){
		tr[no] = l;
		return;
	}
	int nxt = (no<<1), mid = (l+r)>>1;
	build(nxt,l,mid); build(nxt+1,mid+1,r);
	tr[no] = join(tr[nxt],tr[nxt+1]);
}

int query( int no, int l, int r, int i, int j ){
	if( r < i || l > j ) return -1;
	if( l >= i && r <= j ) return tr[no];
	int nxt = (no<<1), mid = (l+r)>>1;
	return join(query(nxt,l,mid,i,j),query(nxt+1,mid+1,r,i,j));
}

int tr2[4*N];

int join2( int a, int b ){
	if( a == -1 ) return b;
	if( b == -1 ) return a;
	if( v[a] >= v[b] ) return a;
	else return b;
}

void build2( int no, int l, int r ){
	if( l == r ){
		tr2[no] = l;
		return;
	}
	int nxt = (no<<1), mid = (l+r)>>1;
	build2(nxt,l,mid); build2(nxt+1,mid+1,r);
	tr2[no] = join2(tr2[nxt],tr2[nxt+1]);
}

int query2( int no, int l, int r, int i, int j ){
	if( r < i || l > j ) return -1;
	if( l >= i && r <= j ) return tr2[no];
	int nxt = (no<<1), mid = (l+r)>>1;
	return join2(query2(nxt,l,mid,i,j),query2(nxt+1,mid+1,r,i,j));
}

int main()
{
	//ios::sync_with_stdio(0);
	scanf("%d",&n);
	for(int i=0;i<n;++i){
		scanf("%lld",v+i);
	}
	build(1,0,n-1);
	build2(1,0,n-1);
	ll qtd = 0;

	int p1, p2;
	p1 = 0, p2 = n-1;
	while( p1 <= p2 ){
		qtd++;
		int x1 = query(1,0,n-1,p1,p2), x2 = query2(1,0,n-1,p1,p2);
		if( x1 < x2 ){
			qtd++;
			p1 = x1+1;
			p2 = x2-1;
		}
		else break;
	}
	printf("%lld\n",qtd);

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector< ii > vii;

#define INF 0x3F3F3F3F
#define LINF 0x3F3F3F3F3F3F3F3FLL
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define LSONE(s) ((s)&(-s)) //LASTBIT
#define DEG_to_RAD(X)   (X * PI / 180)
#define F first
#define S second
#define PI 2*acos(0)

#ifdef ONLINE_JUDGE
#define debug(args...)
#else
#define debug(args...) fprintf(stderr,args)
#endif

//////////////////////
int dx[] = {1,-1,0,0};
int dy[] = {0,0,-1,1};
//////////////////////

void arquivo()
{
	freopen("","r",stdin);
	freopen("","w",stdout);
}

const int N = 100001;

ll v[N];
int n;
int tr[4*N];

int join( int a, int b ){
	if( a == -1 ) return b;
	if( b == -1 ) return a;
	if( v[a] < v[b] ) return a;
	else if( v[b] > v[a] ) return b;
	else
	{
		return b;
	}
}

void build( int no, int l, int r ){
	if( l == r ){
		tr[no] = l;
		return;
	}
	int nxt = (no<<1), mid = (l+r)>>1;
	build(nxt,l,mid); build(nxt+1,mid+1,r);
	tr[no] = join(tr[nxt],tr[nxt+1]);
}

int query( int no, int l, int r, int i, int j ){
	if( r < i || l > j ) return -1;
	if( l >= i && r <= j ) return tr[no];
	int nxt = (no<<1), mid = (l+r)>>1;
	return join(query(nxt,l,mid,i,j),query(nxt+1,mid+1,r,i,j));
}

int main()
{
	//ios::sync_with_stdio(0);
	scanf("%d",&n);
	for(int i=0;i<n;++i){
		scanf("%lld",v+i);
	}
	build(1,0,n-1);
	int pos = 0;
	ll qtd = 0;
	while( pos != n ){
		qtd++;
		pos = query(1,0,n-1,pos,n-1)+1;
	}
	printf("%lld\n",qtd);

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector< ii > vii;

#define INF 0x3F3F3F3F
#define LINF 0x3F3F3F3F3F3F3F3FLL
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define LSONE(s) ((s)&(-s)) //LASTBIT
#define DEG_to_RAD(X)   (X * PI / 180)
#define F first
#define S second
#define PI 2*acos(0)

#ifdef ONLINE_JUDGE
#define debug(args...)
#else
#define debug(args...) fprintf(stderr,args)
#endif

//////////////////////
int dx[] = {1,-1,0,0};
int dy[] = {0,0,-1,1};
//////////////////////

void arquivo()
{
	freopen("","r",stdin);
	freopen("","w",stdout);
}

const int N = 100001;

ll v[N];
int n;
ll ord[N];
map< int, set<int> > marc;
int vai[N];

vii seg;

int main()
{
	//ios::sync_with_stdio(0);
	scanf("%d",&n);
	for(int i=0;i<n;++i){
		scanf("%lld",v+i);
		ord[i] = v[i];
	}
	sort(ord,ord+n);
	for(int i=0;i<n;++i){
		marc[ord[i]].insert(i);
	}

	for(int i=0;i<n;++i){
		int x = v[i];
		vai[i] = *marc[x].begin();
		marc[x].erase(marc[x].begin());
		if( i < vai[i] ){
			seg.pb(mp(i,0));
			seg.pb(mp(vai[i],1));
		}
		else{
			seg.pb(mp(vai[i],0));
			seg.pb(mp(i,1));
		}
	}

	sort(seg.begin(),seg.end());
	ll qtd = 0;
	ll foo = 0;
	for(int i=0;i<seg.size();++i){
		if( seg[i].S == 0 ){
			qtd+=(foo==0);
			foo++;
		}
		else{
			foo--;
		}
	}
	printf("%lld\n",qtd);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector< ii > vii;

#define INF 0x3F3F3F3F
#define LINF 0x3F3F3F3F3F3F3F3FLL
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define LSONE(s) ((s)&(-s)) //LASTBIT
#define DEG_to_RAD(X)   (X * PI / 180)
#define F first
#define S second
#define PI 2*acos(0)

#ifdef ONLINE_JUDGE
#define debug(args...)
#else
#define debug(args...) fprintf(stderr,args)
#endif

//////////////////////
int dx[] = {1,-1,0,0};
int dy[] = {0,0,-1,1};
//////////////////////

void arquivo()
{
	freopen("","r",stdin);
	freopen("","w",stdout);
}

const int N = 100001;

ll v[N];
int n;
int tr[4*N];

int join( int a, int b ){
	if( a == -1 ) return b;
	if( b == -1 ) return a;
	if( v[a] < v[b] ) return a;
	else return b;
}

void build( int no, int l, int r ){
	if( l == r ){
		tr[no] = l;
		return;
	}
	int nxt = (no<<1), mid = (l+r)>>1;
	build(nxt,l,mid); build(nxt+1,mid+1,r);
	tr[no] = join(tr[nxt],tr[nxt+1]);
}

int query( int no, int l, int r, int i, int j ){
	if( r < i || l > j ) return -1;
	if( l >= i && r <= j ) return tr[no];
	int nxt = (no<<1), mid = (l+r)>>1;
	return join(query(nxt,l,mid,i,j),query(nxt+1,mid+1,r,i,j));
}

int tr2[4*N];

int join2( int a, int b ){
	if( a == -1 ) return b;
	if( b == -1 ) return a;
	if( v[a] >= v[b] ) return a;
	else return b;
}

void build2( int no, int l, int r ){
	if( l == r ){
		tr2[no] = l;
		return;
	}
	int nxt = (no<<1), mid = (l+r)>>1;
	build2(nxt,l,mid); build2(nxt+1,mid+1,r);
	tr2[no] = join2(tr2[nxt],tr2[nxt+1]);
}

int query2( int no, int l, int r, int i, int j ){
	if( r < i || l > j ) return -1;
	if( l >= i && r <= j ) return tr2[no];
	int nxt = (no<<1), mid = (l+r)>>1;
	return join2(query2(nxt,l,mid,i,j),query2(nxt+1,mid+1,r,i,j));
}

int main()
{
	//ios::sync_with_stdio(0);
	scanf("%d",&n);
	for(int i=0;i<n;++i){
		scanf("%lld",v+i);
	}
	build(1,0,n-1);
	build2(1,0,n-1);
	ll qtd = 0;

	int p1, p2;
	p1 = 0, p2 = n-1;
	while( p1 < p2 ){
		qtd++;
		int x1 = query(1,0,n-1,p1,p2), x2 = query2(1,0,n-1,p1,p2);
		if( x1 < x2 ){
			qtd++;
			p1 = x1+1;
			p2 = x2-1;
		}
		else break;
	}
	printf("%lld\n",qtd);

	return 0;
}