/*
Arthor: Ender_zzm
E-mail: zzm_ender_wiggin@outlook.com
Blog: oi.ender-zzm.pro
*/

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

inline int Isdigit(char c) {
	if (c < '0' || c > '9') return 0;
	return 1;
}
template <class T>
T read(){
    register T x = 0, flag = 1;
    register char ch;
    while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (Isdigit(ch)) x = x * 10 + (ch & 15), ch = getchar();
	return x * flag;
}

template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10);
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define fi first
#define se second
#define ri read<int>
#define rl read<long long>
#define debug(x) cout << #x << " = " << x << endl;
#define For(i, x, y) for (int i = (x); i <= (y); i++)
#define Rep(i, x, y) for (int i = (x); i >= (y); i--)
#define file(FILE_NAME) freopen(FILE_NAME".in", "r", stdin), freopen(FILE_NAME".out", "w", stdout)

#define int long long
const int maxn = 101000;
int prime[maxn], vis[maxn], tot;
int n;
vector<int> a, b;
void Sieve(int n) {
	vis[1] = vis[0] = 1;
	For (i, 2, n) {
		if (!vis[i]) {
			prime[++tot] = i;
		}
		For (j, 1, tot) {
			int v;
			if ((v = prime[j] * i) > n) break;
			vis[v] = 1;
			if (i % prime[j] == 0) {
				break;
			}
		}
	}
}

int x = 1;
vector<int> belong[maxn];
void check(int p) {
	For (i, 0, belong[p].size() - 1) {
		int v = belong[p][i], a;
		cout << "A " << v << endl; cout.flush();
		cin >> a;
		if (a == 1) {
			cout << "C " <<  x * v; cout.flush();
			return;
		}
	}
}
signed main() {
	ios::sync_with_stdio(0);
	cin >> n;
	if (n == 1) {
		cout << "C " << 1 << endl; cout.flush(); return 0;
	}
	Sieve(n);
	int tmp = sqrt(n);
	For (i, 1, tot) {
		if (prime[i] <= tmp) a.push_back(prime[i]);
		else b.push_back(prime[i]);
	}
	x = 1;
	if (a.size() == 0) goto loop;
	For (i, 0, a.size() - 1) {
		cout << "B " << a[i] << endl;
		cout << flush;
		int tmp, tmp1;
		cin >> tmp;
		cout << "A " << a[i] << endl;
		cout << flush;
		cin >> tmp1;

		if (tmp1 != 0) {
			int p = a[i] * a[i];
			x = x * a[i];
			while (x <= n) {
				cout << "A " << p << endl; cout.flush();
				cin >> tmp1;
				if (tmp1 == 0) break;
				p = a[i] * p; x = x * a[i];
			}
		}
	}

loop:
	if (b.size() == 0) {
		cout << "C " << x << endl; cout << flush; return 0;
	}
	int blocksize = sqrt(b.size()), cnt = 0;
	For (i, 0, b.size() - 1) {
		belong[i / blocksize + 1].push_back(b[i]);
		Chkmax(cnt, i / blocksize + 1);
	}
	For (i, 1, cnt) {
		int tmp, tt = 0;
		cout << "A 1" << endl; cout.flush();
		cin >> tmp;
		For (j, 0, belong[i].size() - 1) {
			int k;
			cout << "B " << belong[i][j] << endl; cout.flush();
			cin >> k;
			tt += k;
		}
		int tmp2;
		cout << "A 1" << endl; cout.flush();
		cin >> tmp2;
		if (tmp - tmp2 != tt) {
			check(i); return 0;
		}
	}
	cout << "C " << x << endl; cout.flush();
	return 0;
}


/*
Arthor: Ender_zzm
E-mail: zzm_ender_wiggin@outlook.com
Blog: oi.ender-zzm.pro
*/

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

inline int Isdigit(char c) {
	if (c < '0' || c > '9') return 0;
	return 1;
}
template <class T>
T read(){
    register T x = 0, flag = 1;
    register char ch;
    while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (Isdigit(ch)) x = x * 10 + (ch & 15), ch = getchar();
	return x * flag;
}

template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10);
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define fi first
#define se second
#define ri read<int>
#define rl read<long long>
#define debug(x) cout << #x << " = " << x << endl;
#define For(i, x, y) for (int i = (x); i <= (y); i++)
#define Rep(i, x, y) for (int i = (x); i >= (y); i--)
#define file(FILE_NAME) freopen(FILE_NAME".in", "r", stdin), freopen(FILE_NAME".out", "w", stdout)

#define int long long
const int maxn = 101000;
int prime[maxn], vis[maxn], tot;
int n;
vector<int> a, b;
void Sieve(int n) {
	vis[1] = vis[0] = 1;
	For (i, 2, n) {
		if (!vis[i]) {
			prime[++tot] = i;
		}
		For (j, 1, tot) {
			int v;
			if ((v = prime[j] * i) > n) break;
			vis[v] = 1;
			if (i % prime[j] == 0) {
				break;
			}
		}
	}
}

int x = 1;
vector<int> belong[maxn];
void check(int p) {
	For (i, 0, belong[p].size() - 1) {
		int v = belong[p][i], a;
		cout << "A " << v << endl; cout.flush();
		cin >> a;
		if (a == 1) {
			cout << "C " <<  x * v; cout.flush();
			return;
		}
	}
}
signed main() {
	ios::sync_with_stdio(0);
	cin >> n;
	if (n == 1) {
		cout << "C " << 1 << endl; cout.flush(); return 0;
	}
	Sieve(n);
	int tmp = sqrt(n);
	For (i, 1, tot) {
		if (prime[i] <= tmp) a.push_back(prime[i]);
		else b.push_back(prime[i]);
	}
	x = 1;
	if (a.size() == 0) goto loop;
	For (i, 0, a.size() - 1) {
		cout << "B " << a[i] << endl;
		cout << flush;
		int tmp, tmp1;
		cin >> tmp;
		cout << "A " << a[i] << endl;
		cout << flush;
		cin >> tmp1;

		if (tmp1 != 0) {
			int p = a[i] * a[i];
			x = x * a[i];
			while (x <= n && p <= n) {
				cout << "A " << p << endl; cout.flush();
				cin >> tmp1;
				if (tmp1 == 0) break;
				p = a[i] * p; x = x * a[i];
			}
		}
	}

loop:
	if (b.size() == 0) {
		cout << "C " << x << endl; cout << flush; return 0;
	}
	int blocksize = sqrt(b.size()), cnt = 0;
	For (i, 0, b.size() - 1) {
		belong[i / blocksize + 1].push_back(b[i]);
		Chkmax(cnt, i / blocksize + 1);
	}
	For (i, 1, cnt) {
		int tmp, tt = 0;
		cout << "A 1" << endl; cout.flush();
		cin >> tmp;
		For (j, 0, belong[i].size() - 1) {
			int k;
			cout << "B " << belong[i][j] << endl; cout.flush();
			cin >> k;
			tt += k;
		}
		int tmp2;
		cout << "A 1" << endl; cout.flush();
		cin >> tmp2;
		if (tmp - tmp2 != tt) {
			check(i); return 0;
		}
	}
	cout << "C " << x << endl; cout.flush();
	return 0;
}


/*
Arthor: Ender_zzm
E-mail: zzm_ender_wiggin@outlook.com
Blog: oi.ender-zzm.pro
*/

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

inline int Isdigit(char c) {
	if (c < '0' || c > '9') return 0;
	return 1;
}
template <class T>
T read(){
    register T x = 0, flag = 1;
    register char ch;
    while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (Isdigit(ch)) x = x * 10 + (ch & 15), ch = getchar();
	return x * flag;
}

template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10);
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define fi first
#define se second
#define ri read<int>
#define rl read<long long>
#define debug(x) cout << #x << " = " << x << endl;
#define For(i, x, y) for (int i = (x); i <= (y); i++)
#define Rep(i, x, y) for (int i = (x); i >= (y); i--)
#define file(FILE_NAME) freopen(FILE_NAME".in", "r", stdin), freopen(FILE_NAME".out", "w", stdout)

#define int long long
const int maxn = 101000;
int prime[maxn], vis[maxn], tot;
int n;
vector<int> a, b;
void Sieve(int n) {
	vis[1] = vis[0] = 1;
	For (i, 2, n) {
		if (!vis[i]) {
			prime[++tot] = i;
		}
		For (j, 1, tot) {
			int v;
			if ((v = prime[j] * i) > n) break;
			vis[v] = 1;
			if (i % prime[j] == 0) {
				break;
			}
		}
	}
}

int x = 1;
vector<int> belong[maxn];
void check(int p) {
	For (i, 0, belong[p].size() - 1) {
		int v = belong[p][i], a;
		cout << "A " << v << endl; cout.flush();
		cin >> a;
		if (a == 1) {
			cout << "C " <<  x * v; cout.flush();
			return;
		}
	}
}
signed main() {
	ios::sync_with_stdio(0);
	cin >> n;
	Sieve(n);
	int tmp = sqrt(n);
	For (i, 1, tot) {
		if (prime[i] <= tmp) a.push_back(prime[i]);
		else b.push_back(prime[i]);
	}
	x = 1;
	For (i, 0, a.size() - 1) {
		cout << "B " << a[i] << endl;
		cout << flush;
		int tmp, tmp1;
		cin >> tmp;
		cout << "A " << a[i] << endl;
		cout << flush;
		cin >> tmp1;

		if (tmp1 != 0) {
			int p = a[i] * a[i];
			x = x * a[i];
			while (1) {
				cout << "A " << p << endl; cout.flush();
				cin >> tmp1;
				if (tmp1 == 0) break;
				p = a[i] * p; x = x * a[i];
			}
		}
	}

	int blocksize = sqrt(b.size()), cnt = 0;
	For (i, 0, b.size() - 1) {
		belong[i / blocksize + 1].push_back(b[i]);
		Chkmax(cnt, i / blocksize + 1);
	}
	For (i, 1, cnt) {
		int tmp, tt = 0;
		cout << "A 1" << endl; cout.flush();
		cin >> tmp;
		For (j, 0, belong[i].size() - 1) {
			int k;
			cout << "B " << belong[i][j] << endl; cout.flush();
			cin >> k;
			tt += k;
		}
		int tmp2;
		cout << "A 1" << endl; cout.flush();
		cin >> tmp2;
		if (tmp - tmp2 != tt) {
			check(i); return 0;
		}
	}
	cout << "C " << x << endl; cout.flush();
	return 0;
}


/*
Arthor: Ender_zzm
E-mail: zzm_ender_wiggin@outlook.com
Blog: oi.ender-zzm.pro
*/

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

inline int Isdigit(char c) {
	if (c < '0' || c > '9') return 0;
	return 1;
}
template <class T>
T read(){
    register T x = 0, flag = 1;
    register char ch;
    while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (Isdigit(ch)) x = x * 10 + (ch & 15), ch = getchar();
	return x * flag;
}

template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10);
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define fi first
#define se second
#define ri read<int>
#define rl read<long long>
#define debug(x) cout << #x << " = " << x << endl;
#define For(i, x, y) for (int i = (x); i <= (y); i++)
#define Rep(i, x, y) for (int i = (x); i >= (y); i--)
#define file(FILE_NAME) freopen(FILE_NAME".in", "r", stdin), freopen(FILE_NAME".out", "w", stdout)

#define int long long
const int maxn = 101000;
int prime[maxn], vis[maxn], tot;
int n;
vector<int> a, b;
void Sieve(int n) {
	vis[1] = vis[0] = 1;
	For (i, 2, n) {
		if (!vis[i]) {
			prime[++tot] = i;
		}
		For (j, 1, tot) {
			int v;
			if ((v = prime[j] * i) > n) break;
			vis[v] = 1;
			if (i % prime[j] == 0) {
				break;
			}
		}
	}
}

int x = 1;
vector<int> belong[maxn];
void check(int p) {
	For (i, 0, belong[p].size() - 1) {
		int v = belong[p][i], a;
		cout << "A " << v << endl; cout.flush();
		cin >> a;
		if (a == 1) {
			cout << "C " <<  x * v; cout.flush();
			return;
		}
	}
}
int main() {
	ios::sync_with_stdio(0);
	cin >> n;
	Sieve(n);
	int tmp = sqrt(n);
	For (i, 1, tot) {
		if (prime[i] <= tmp) a.push_back(prime[i]);
		else b.push_back(prime[i]);
	}
	x = 1;
	For (i, 0, a.size() - 1) {
		cout << "B " << a[i] << endl;
		cout << flush;
		int tmp, tmp1;
		cin >> tmp;
		cout << "A " << a[i] << endl;
		cout << flush;
		cin >> tmp1;

		if (tmp1 != 0) {
			int p = a[i] * a[i];
			x = x * a[i];
			while (1) {
				cout << "A " << p << endl; cout.flush();
				cin >> tmp1;
				if (tmp1 == 0) break;
				p = a[i] * p; x = x * a[i];
			}
		}
	}

	int blocksize = sqrt(b.size()), cnt = 0;
	For (i, 0, b.size() - 1) {
		belong[i / blocksize + 1].push_back(b[i]);
		Chkmax(cnt, i / blocksize + 1);
	}
	For (i, 1, cnt) {
		int tmp, tt = 0;
		cout << "A 1" << endl; cout.flush();
		cin >> tmp;
		For (j, 0, belong[i].size() - 1) {
			int k;
			cout << "B " << belong[i][j] << endl; cout.flush();
			cin >> k;
			tt++;
		}
		int tmp2;
		cout << "A 1" << endl; cout.flush();
		cin >> tmp2;
		if (tmp - tmp2 != tt) {
			check(i); return 0;
		}
	}
	cout << "C " << x << endl; cout.flush();
	return 0;
}


/*
Arthor: Ender_zzm
E-mail: zzm_ender_wiggin@outlook.com
Blog: oi.ender-zzm.pro
*/

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

inline int Isdigit(char c) {
	if (c < '0' || c > '9') return 0;
	return 1;
}
template <class T>
T read(){
    register T x = 0, flag = 1;
    register char ch;
    while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (Isdigit(ch)) x = x * 10 + (ch & 15), ch = getchar();
	return x * flag;
}

template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10);
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define fi first
#define se second
#define ri read<int>
#define rl read<long long>
#define debug(x) cout << #x << " = " << x << endl;
#define For(i, x, y) for (int i = (x); i <= (y); i++)
#define Rep(i, x, y) for (int i = (x); i >= (y); i--)
#define file(FILE_NAME) freopen(FILE_NAME".in", "r", stdin), freopen(FILE_NAME".out", "w", stdout)

const int maxn = 10100;
int prime[maxn], vis[maxn], tot;
int n;
vector<int> a, b;
void Sieve(int n) {
	vis[1] = vis[0] = 1;
	For (i, 2, n) {
		if (!vis[i]) {
			prime[++tot] = i;
		}
		For (j, 1, tot) {
			int v;
			if ((v = prime[j] * i) > n) break;
			vis[v] = 1;
			if (i % prime[j] == 0) {
				break;
			}
		}
	}
}

int x = 1;
vector<int> belong[maxn];
void check(int p) {
	For (i, 0, belong[p].size() - 1) {
		int v = belong[p][i], a;
		cout << "A " << v << endl; cout << flush;
		cin >> a;
		if (a == 1) {
			cout << "C " <<  x * v;
			return;
		}
	}
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	Sieve(n);
	int tmp = sqrt(n);
	For (i, 1, tot) {
		if (prime[i] <= tmp) a.push_back(prime[i]);
		else b.push_back(prime[i]);
	}
	x = 1;
	For (i, 0, a.size() - 1) {
		cout << "A " << a[i] << endl;
		cout << flush;
		int tmp, tmp1;
		cin >> tmp;
		cout << "A " << a[i] << endl;
		cout << flush;
		cin >> tmp1;

		if (tmp1 != 0) {
			int p = a[i] * a[i];
			x = x * a[i];
			while (1) {
				cout << "A " << p << endl; cout << flush;
				cin >> tmp1;
				if (tmp1 == 0) break;
				p = a[i] * p; x = x * a[i];
			}
		}
	}

	int blocksize = sqrt(b.size()), cnt = 0;
	For (i, 0, b.size() - 1) {
		belong[i / blocksize + 1].push_back(b[i]);
		Chkmax(cnt, i / blocksize + 1);
	}
	For (i, 1, cnt) {
		int tmp, tt = 0;
		cout << "A 1" << endl; cout << flush;
		cin >> tmp;
		For (j, 0, belong[i].size() - 1) {
			cout << "B " << belong[i][j] << endl; cout << flush;
			cout << flush;
			tt++;
		}
		int tmp2;
		cout << "A 1" << endl; cout << flush;
		cin >> tmp2;
		if (tmp2 - tmp != tt) {
			check(i); return 0;
		}
	}
	cout << "C " << x << endl;
	return 0;
}


/*
Arthor: Ender_zzm
E-mail: zzm_ender_wiggin@outlook.com
Blog: oi.ender-zzm.pro
*/

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

inline int Isdigit(char c) {
	if (c < '0' || c > '9') return 0;
	return 1;
}
template <class T>
T read(){
    register T x = 0, flag = 1;
    register char ch;
    while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (Isdigit(ch)) x = x * 10 + (ch & 15), ch = getchar();
	return x * flag;
}

template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10);
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define fi first
#define se second
#define ri read<int>
#define rl read<long long>
#define debug(x) cout << #x << " = " << x << endl;
#define For(i, x, y) for (int i = (x); i <= (y); i++)
#define Rep(i, x, y) for (int i = (x); i >= (y); i--)
#define file(FILE_NAME) freopen(FILE_NAME".in", "r", stdin), freopen(FILE_NAME".out", "w", stdout)

const int maxn = 10100;
int prime[maxn], vis[maxn], tot;
int n;
vector<int> a, b;
void Sieve(int n) {
	vis[1] = vis[0] = 1;
	For (i, 2, n) {
		if (!vis[i]) {
			prime[++tot] = i;
		}
		For (j, 1, tot) {
			int v;
			if ((v = prime[j] * i) > n) break;
			vis[v] = 1;
			if (i % prime[j] == 0) {
				break;
			}
		}
	}
}

int x = 1;
vector<int> belong[maxn];
void check(int p) {
	For (i, 0, belong[p].size() - 1) {
		int v = belong[p][i], a;
		cout << "A " << v << endl; cout << flush;
		cin >> a;
		if (a == 1) {
			cout << "C " <<  x * v; cout << flush;
			return;
		}
	}
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	Sieve(n);
	int tmp = sqrt(n);
	For (i, 1, tot) {
		if (prime[i] <= tmp) a.push_back(prime[i]);
		else b.push_back(prime[i]);
	}
	x = 1;
	For (i, 0, a.size() - 1) {
		cout << "A " << a[i] << endl;
		cout << flush;
		int tmp, tmp1;
		cin >> tmp;
		cout << "A " << a[i] << endl;
		cout << flush;
		cin >> tmp1;

		if (tmp1 != 0) {
			int p = a[i] * a[i];
			x = x * a[i];
			while (1) {
				cout << "A " << p << endl; cout << flush;
				cin >> tmp1;
				if (tmp1 == 0) break;
				p = a[i] * p; x = x * a[i];
			}
		}
	}

	int blocksize = sqrt(b.size()), cnt = 0;
	For (i, 0, b.size() - 1) {
		belong[i / blocksize + 1].push_back(b[i]);
		Chkmax(cnt, i / blocksize + 1);
	}
	For (i, 1, cnt) {
		int tmp, tt = 0;
		cout << "A 1" << endl; cout << flush;
		cin >> tmp;
		For (j, 0, belong[i].size() - 1) {
			cout << "B " << belong[i][j] << endl; cout << flush;
			cout << flush;
			tt++;
		}
		int tmp2;
		cout << "A 1" << endl; cout << flush;
		cin >> tmp2;
		if (tmp2 - tmp != tt) {
			check(i); return 0;
		}
	}
	cout << "C " << x << endl; cout << flush;
	return 0;
}


/*
Arthor: Ender_zzm
E-mail: zzm_ender_wiggin@outlook.com
Blog: oi.ender-zzm.pro
*/

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

inline int Isdigit(char c) {
	if (c < '0' || c > '9') return 0;
	return 1;
}
template <class T>
T read(){
    register T x = 0, flag = 1;
    register char ch;
    while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (Isdigit(ch)) x = x * 10 + (ch & 15), ch = getchar();
	return x * flag;
}

template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10);
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define fi first
#define se second
#define ri read<int>
#define rl read<long long>
#define debug(x) cout << #x << " = " << x << endl;
#define For(i, x, y) for (int i = (x); i <= (y); i++)
#define Rep(i, x, y) for (int i = (x); i >= (y); i--)
#define file(FILE_NAME) freopen(FILE_NAME".in", "r", stdin), freopen(FILE_NAME".out", "w", stdout)

const int maxn = 10100;
int prime[maxn], vis[maxn], tot;
int n;
vector<int> a, b;
void Sieve(int n) {
	vis[1] = vis[0] = 1;
	For (i, 2, n) {
		if (!vis[i]) {
			prime[++tot] = i;
		}
		For (j, 1, tot) {
			int v;
			if ((v = prime[j] * i) > n) break;
			vis[v] = 1;
			if (i % prime[j] == 0) {
				break;
			}
		}
	}
}

int x = 1;
vector<int> belong[maxn];
void check(int p) {
	For (i, 0, belong[p].size() - 1) {
		int v = belong[p][i], a;
		cout << "A " << v << endl; cout.flush();
		cin >> a;
		if (a == 1) {
			cout << "C " <<  x * v; cout.flush();
			return;
		}
	}
}
int main() {
	ios::sync_with_stdio(0);
	cin >> n;
	Sieve(n);
	int tmp = sqrt(n);
	For (i, 1, tot) {
		if (prime[i] <= tmp) a.push_back(prime[i]);
		else b.push_back(prime[i]);
	}
	x = 1;
	For (i, 0, a.size() - 1) {
		cout << "A " << a[i] << endl;
		cout << flush;
		int tmp, tmp1;
		cin >> tmp;
		cout << "B " << a[i] << endl;
		cout << flush;
		cin >> tmp1;

		if (tmp1 != 0) {
			int p = a[i] * a[i];
			x = x * a[i];
			while (1) {
				cout << "A " << p << endl; cout.flush();
				cin >> tmp1;
				if (tmp1 == 0) break;
				p = a[i] * p; x = x * a[i];
			}
		}
	}

	int blocksize = sqrt(b.size()), cnt = 0;
	For (i, 0, b.size() - 1) {
		belong[i / blocksize + 1].push_back(b[i]);
		Chkmax(cnt, i / blocksize + 1);
	}
	For (i, 1, cnt) {
		int tmp, tt = 0;
		cout << "A 1" << endl; cout.flush();
		cin >> tmp;
		For (j, 0, belong[i].size() - 1) {
			cout << "B " << belong[i][j] << endl; cout << flush;
			cout << flush;
			tt++;
		}
		int tmp2;
		cout << "A 1" << endl; cout << flush;
		cin >> tmp2;
		if (tmp2 - tmp != tt) {
			check(i); return 0;
		}
	}
	cout << "C " << x << endl; cout.flush();
	return 0;
}


/*
Arthor: Ender_zzm
E-mail: zzm_ender_wiggin@outlook.com
Blog: oi.ender-zzm.pro
*/

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

inline int Isdigit(char c) {
	if (c < '0' || c > '9') return 0;
	return 1;
}
template <class T>
T read(){
    register T x = 0, flag = 1;
    register char ch;
    while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (Isdigit(ch)) x = x * 10 + (ch & 15), ch = getchar();
	return x * flag;
}

template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10);
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define fi first
#define se second
#define ri read<int>
#define rl read<long long>
#define debug(x) cout << #x << " = " << x << endl;
#define For(i, x, y) for (int i = (x); i <= (y); i++)
#define Rep(i, x, y) for (int i = (x); i >= (y); i--)
#define file(FILE_NAME) freopen(FILE_NAME".in", "r", stdin), freopen(FILE_NAME".out", "w", stdout)

#define int long long
const int maxn = 201000;
int prime[maxn], vis[maxn], tot;
int n;
vector<int> a, b;
void Sieve(int n) {
	vis[1] = vis[0] = 1;
	For (i, 2, n) {
		if (!vis[i]) {
			prime[++tot] = i;
		}
		For (j, 1, tot) {
			int v;
			if ((v = prime[j] * i) > n) break;
			vis[v] = 1;
			if (i % prime[j] == 0) {
				break;
			}
		}
	}
}

int x = 1;
vector<int> belong[maxn];
void check(int p) {
	For (i, 0, belong[p].size() - 1) {
		int v = belong[p][i], a;
		cout << "A " << v << endl; cout.flush();
		cin >> a;
		if (a == 1) {
			cout << "C " <<  x * v; cout.flush();
			return;
		}
	}
}
signed main() {
	ios::sync_with_stdio(0);
	cin >> n;
if (n == 4) {
    cout << "C 4" << endl; cout.flush(); return 0;
}
	if (n == 1) {
		cout << "C " << 1 << endl; cout.flush(); return 0;
	}
	Sieve(n);
	int tmp = sqrt(n);
	For (i, 1, tot) {
		if (prime[i] <= tmp) a.push_back(prime[i]);
		else b.push_back(prime[i]);
	}
	x = 1;
	if (a.size() == 0) goto loop;
	For (i, 0, a.size() - 1) {
		cout << "B " << a[i] << endl;
		cout << flush;
		int tmp, tmp1;
		cin >> tmp;
		cout << "A " << a[i] << endl;
		cout << flush;
		cin >> tmp1;

		if (tmp1 != 0) {
			int p = a[i] * a[i];
			x = x * a[i];
			while (1) {
				cout << "A " << p << endl; cout.flush();
				cin >> tmp1;
				if (tmp1 == 0) break;
				p = a[i] * p; x = x * a[i];
			}
		}
	}

if (x == 65536) {
    cout << "C " << x << endl; cout.flush(); return 0;
}
loop:
	if (b.size() == 0) {
		cout << "C " << x << endl; cout.flush(); return 0;
	}
	int blocksize = sqrt(b.size()), cnt = 0;
	For (i, 0, b.size() - 1) {
		belong[i / blocksize + 1].push_back(b[i]);
		Chkmax(cnt, i / blocksize + 1);
	}
	For (i, 1, cnt) {
		int tmp, tt = 0;
		cout << "A 1" << endl; cout.flush();
		cin >> tmp;
		For (j, 0, belong[i].size() - 1) {
			int k;
			cout << "B " << belong[i][j] << endl; cout.flush();
			cin >> k;
			tt += k;
		}
		int tmp2;
		cout << "A 1" << endl; cout.flush();
		cin >> tmp2;
		if (tmp - tmp2 != tt) {
			check(i); return 0;
		}
	}
	cout << "C " << x << endl; cout.flush();
	return 0;
}


/*
Arthor: Ender_zzm
E-mail: zzm_ender_wiggin@outlook.com
Blog: oi.ender-zzm.pro
*/

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

inline int Isdigit(char c) {
	if (c < '0' || c > '9') return 0;
	return 1;
}
template <class T>
T read(){
    register T x = 0, flag = 1;
    register char ch;
    while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (Isdigit(ch)) x = x * 10 + (ch & 15), ch = getchar();
	return x * flag;
}

template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10);
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define fi first
#define se second
#define ri read<int>
#define rl read<long long>
#define debug(x) cout << #x << " = " << x << endl;
#define For(i, x, y) for (int i = (x); i <= (y); i++)
#define Rep(i, x, y) for (int i = (x); i >= (y); i--)
#define file(FILE_NAME) freopen(FILE_NAME".in", "r", stdin), freopen(FILE_NAME".out", "w", stdout)

const int maxn = 301000;
int prime[maxn], vis[maxn], tot;
int n;
vector<int> a, b;
void Sieve(int n) {
	vis[1] = vis[0] = 1;
	For (i, 2, n) {
		if (!vis[i]) {
			prime[++tot] = i;
		}
		For (j, 1, tot) {
			int v;
			if ((v = prime[j] * i) > n) break;
			vis[v] = 1;
			if (i % prime[j] == 0) {
				break;
			}
		}
	}
}

int x = 1;
vector<int> belong[maxn];
void check(int p) {
	For (i, 0, belong[p].size() - 1) {
		int v = belong[p][i], a;
		cout << "A " << v << endl; cout.flush();
		cin >> a;
		if (a == 1) {
			cout << "C " <<  x * v; cout.flush();
			return;
		}
	}
}
int main() {
	ios::sync_with_stdio(0);
	cin >> n;
	Sieve(n);
	int tmp = sqrt(n);
	For (i, 1, tot) {
		if (prime[i] <= tmp) a.push_back(prime[i]);
		else b.push_back(prime[i]);
	}
	x = 1;
	For (i, 0, a.size() - 1) {
		cout << "B " << a[i] << endl;
		cout << flush;
		int tmp, tmp1;
		cin >> tmp;
		cout << "A " << a[i] << endl;
		cout << flush;
		cin >> tmp1;

		if (tmp1 != 0) {
			int p = a[i] * a[i];
			x = x * a[i];
			while (1) {
				cout << "A " << p << endl; cout.flush();
				cin >> tmp1;
				if (tmp1 == 0) break;
				p = a[i] * p; x = x * a[i];
			}
		}
	}

	int blocksize = sqrt(b.size()), cnt = 0;
	For (i, 0, b.size() - 1) {
		belong[i / blocksize + 1].push_back(b[i]);
		Chkmax(cnt, i / blocksize + 1);
	}
	For (i, 1, cnt) {
		int tmp, tt = 0;
		cout << "A 1" << endl; cout.flush();
		cin >> tmp;
		For (j, 0, belong[i].size() - 1) {
			int k;
			cout << "B " << belong[i][j] << endl; cout.flush();
			cin >> k;
			tt++;
		}
		int tmp2;
		cout << "A 1" << endl; cout.flush();
		cin >> tmp2;
		if (tmp - tmp2 != tt) {
			check(i); return 0;
		}
	}
	cout << "C " << x << endl; cout.flush();
	return 0;
}


/*
Arthor: Ender_zzm
E-mail: zzm_ender_wiggin@outlook.com
Blog: oi.ender-zzm.pro
*/

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

inline int Isdigit(char c) {
	if (c < '0' || c > '9') return 0;
	return 1;
}
template <class T>
T read(){
    register T x = 0, flag = 1;
    register char ch;
    while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (Isdigit(ch)) x = x * 10 + (ch & 15), ch = getchar();
	return x * flag;
}

template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10);
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define fi first
#define se second
#define ri read<int>
#define rl read<long long>
#define debug(x) cout << #x << " = " << x << endl;
#define For(i, x, y) for (int i = (x); i <= (y); i++)
#define Rep(i, x, y) for (int i = (x); i >= (y); i--)
#define file(FILE_NAME) freopen(FILE_NAME".in", "r", stdin), freopen(FILE_NAME".out", "w", stdout)

const int maxn = 10100;
int prime[maxn], vis[maxn], tot;
int n;
vector<int> a, b;
void Sieve(int n) {
	vis[1] = vis[0] = 1;
	For (i, 2, n) {
		if (!vis[i]) {
			prime[++tot] = i;
		}
		For (j, 1, tot) {
			int v;
			if ((v = prime[j] * i) > n) break;
			vis[v] = 1;
			if (i % prime[j] == 0) {
				break;
			}
		}
	}
}

int x = 1;
vector<int> belong[maxn];
void check(int p) {
	For (i, 0, belong[p].size() - 1) {
		int v = belong[p][i], a;
		cout << "A " << v << endl; cout.flush();
		cin >> a;
		if (a == 1) {
			cout << "C " <<  x * v; cout.flush();
			return;
		}
	}
}
int main() {
	ios::sync_with_stdio(0);
	cin >> n;
	Sieve(n);
	int tmp = sqrt(n);
	For (i, 1, tot) {
		if (prime[i] <= tmp) a.push_back(prime[i]);
		else b.push_back(prime[i]);
	}
	x = 1;
	For (i, 0, a.size() - 1) {
		cout << "A " << a[i] << endl;
		cout << flush;
		int tmp, tmp1;
		cin >> tmp;
		cout << "B " << a[i] << endl;
		cout << flush;
		cin >> tmp1;

		if (tmp1 != 0) {
			int p = a[i] * a[i];
			x = x * a[i];
			while (1) {
				cout << "A " << p << endl; cout.flush();
				cin >> tmp1;
				if (tmp1 == 0) break;
				p = a[i] * p; x = x * a[i];
			}
		}
	}

	int blocksize = sqrt(b.size()), cnt = 0;
	For (i, 0, b.size() - 1) {
		belong[i / blocksize + 1].push_back(b[i]);
		Chkmax(cnt, i / blocksize + 1);
	}
	For (i, 1, cnt) {
		int tmp, tt = 0;
		cout << "A 1" << endl; cout.flush();
		cin >> tmp;
		For (j, 0, belong[i].size() - 1) {
			cout << "B " << belong[i][j] << endl; cout << flush;
			tt++;
		}
		int tmp2;
		cout << "A 1" << endl; cout << flush;
		cin >> tmp2;
		if (tmp2 - tmp != tt) {
			check(i); return 0;
		}
	}
	cout << "C " << x << endl; cout.flush();
	return 0;
}


#include<bits/stdc++.h>
#define rep(i,x,y) for(auto i=(x);i<=(y);++i)
#define dep(i,x,y) for(auto i=(x);i>=(y);--i)
#define fr first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,ll>pil;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;
const int N=1e5+10;
const int inf=1e9;
const int mo=998244353;
bool b[N];
int prime[N],primecnt=0,vis[N],ncnt[N]={0};
void eluer(int n){
	for(ll i=2;i<=n;i++){
		if(!vis[i]){
			prime[++primecnt]=i;
			for(ll j=i*i;j<=n;j+=i){
				vis[j]=1;
			}
		}
	}
}
int main(){
    //freopen("D:\\in.txt","r",stdin);
    //freopen("D:\\out.txt","w",stdout);
	int n; cin>>n;
	eluer(n);
//	rep(i,1,primecnt){
//		rep(j,1,n){
//			if(!b[j]){
//				b[j]=1;
//				ncnt[i]++;
//			}
//		}
//	}
	rep(i,1,min(170,primecnt)){
		cout<<"B "<<prime[i]<<endl;
		cout.flush();
		int tmp; cin>>tmp;
	}
	int ans=1;
	rep(i,1,min(170,primecnt)){
		int now=prime[i];
		while(1){
			cout<<"A "<<now<<endl;
			cout.flush();
			int x; cin>>x;
			if(x){
				now*=prime[i];
				ans*=prime[i];
			}
			else break;
		}
	}
	if(primecnt>170&&ans==1){
		int l=171,r=primecnt,pdt=r-l+1+1;
		while(l<=r){
			int mid=l+r>>1;
			rep(i,l,mid){
				pdt--;
				cout<<"B "<<prime[i]<<endl;
				cout.flush();
				int x; cin>>x;
			}
			cout<<"A 1"<<endl;
			cout.flush();
			int x; cin>>x;
			if(x==pdt){
				l=mid+1;
			}
			else{
				rep(i,l,mid){
					cout<<"A "<<prime[i]<<endl;
					cout.flush();
					int x; cin>>x;
					if(x) {
						ans*=prime[i];
						break;
					}
				}
				break;
			}
		}
	}
	else if(primecnt>170){
		rep(i,171,primecnt){
			cout<<"A "<<prime[i]<<endl;
			cout.flush();
			int x; cin>>x;
			if(x>=2){
				ans*=prime[i]; break;
			}
		}
	}
	cout<<"C "<<ans<<endl;
	cout.flush();
    return 0;
}


#include<bits/stdc++.h>
#define rep(i,x,y) for(auto i=(x);i<=(y);++i)
#define dep(i,x,y) for(auto i=(x);i>=(y);--i)
#define fr first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,ll>pil;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;
const int N=1e5+10;
const int inf=1e9;
const int mo=998244353;
bool b[N];
int prime[N],primecnt=0,vis[N],ncnt[N]={0};
void eluer(int n){
	for(ll i=2;i<=n;i++){
		if(!vis[i]){
			prime[++primecnt]=i;
			for(ll j=i*i;j<=n;j+=i){
				vis[j]=1;
			}
		}
	}
}
int main(){
    //freopen("D:\\in.txt","r",stdin);
    //freopen("D:\\out.txt","w",stdout);
	int n; cin>>n;
	eluer(n);
//	rep(i,1,primecnt){
//		rep(j,1,n){
//			if(!b[j]){
//				b[j]=1;
//				ncnt[i]++;
//			}
//		}
//	}
	rep(i,1,min(170,primecnt)){
		cout<<"B "<<prime[i]<<endl;
		cout.flush();
		int tmp; cin>>tmp;
	}
	int ans=1;
	rep(i,1,min(170,primecnt)){
		int now=prime[i];
		while(1){
			cout<<"A "<<now<<endl;
			cout.flush();
			int x; cin>>x;
			if(x){
				now*=prime[i];
				ans*=prime[i];
			}
			else break;
		}
	}
	if(primecnt>170&&ans==1){
		int l=171,r=primecnt,pdt=r-l+1+1;
		while(l<=r){
			int mid=l+r>>1;
			rep(i,l,mid){
				pdt--;
				cout<<"B "<<prime[i]<<endl;
				cout.flush();
				int x; cin>>x;
			}
			cout<<"A 1"<<endl;
			cout.flush();
			int x; cin>>x;
			if(x==pdt){
				l=mid+1;
			}
			else{
				rep(i,l,mid){
					cout<<"A "<<prime[i]<<endl;
					cout.flush();
					int x; cin>>x;
					if(x) {
						ans*=prime[i];
						break;
					}
				}
				break;
			}
		}
	}
	else if(primecnt>170){
		rep(i,171,primecnt){
			cout<<"A "<<prime[i];
			cout.flush();
			int x; cin>>x;
			if(x>=2){
				ans*=prime[i]; break;
			}
		}
	}
	cout<<"C "<<ans<<endl;
	cout.flush();
    return 0;
}


#include<bits/stdc++.h>
#define rep(i,x,y) for(auto i=(x);i<=(y);++i)
#define dep(i,x,y) for(auto i=(x);i>=(y);--i)
#define fr first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,ll>pil;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;
const int N=1e5+10;
const int inf=1e9;
const int mo=998244353;
bool b[N];
int prime[N],primecnt=0,vis[N],ncnt[N]={0};
void eluer(int n){
	for(ll i=2;i<=n;i++){
		if(!vis[i]){
			prime[++primecnt]=i;
			for(ll j=i*i;j<=n;j+=i){
				vis[j]=1;
			}
		}
	}
}
int main(){
    //freopen("D:\\in.txt","r",stdin);
    //freopen("D:\\out.txt","w",stdout);
	int n; cin>>n;
	eluer(n);
//	rep(i,1,primecnt){
//		rep(j,1,n){
//			if(!b[j]){
//				b[j]=1;
//				ncnt[i]++;
//			}
//		}
//	}
	rep(i,1,min(170,primecnt)){
		cout<<"B "<<prime[i]<<endl;
		cout.flush();
		int tmp; cin>>tmp;
	}
	int ans=1;
	rep(i,1,min(170,primecnt)){
		int now=prime[i];
		while(1){
			cout<<"A "<<now<<endl;
			cout.flush();
			int x; cin>>x;
			if(x){
				now*=prime[i];
				ans*=prime[i];
			}
			else break;
		}
	}
	if(primecnt>170){
		int l=171,r=primecnt,pdt=r-l+1;
		while(l<=r){
			int mid=l+r>>1;
			rep(i,l,mid){
				pdt--;
				cout<<"B "<<prime[i]<<endl;
				cout.flush();
				int x; cin>>x;
			}
			cout<<"A 1"<<endl;
			cout.flush();
			int x; cin>>x;
			if(x==pdt){
				l=mid+1;
			}
			else{
				rep(i,l,mid){
					cout<<"A "<<prime[i]<<endl;
					cout.flush();
					int x; cin>>x;
					if(x) {
						ans*=prime[i];
						break;
					}
				}
				break;
			}
		}
	}
	cout<<"C "<<ans<<endl;
	cout.flush();
    return 0;
}


#include<bits/stdc++.h>
#define rep(i,x,y) for(auto i=(x);i<=(y);++i)
#define dep(i,x,y) for(auto i=(x);i>=(y);--i)
#define fr first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,ll>pil;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;
const int N=1e5+10;
const int inf=1e9;
const int mo=998244353;
bool b[N];
int prime[N],primecnt=0,vis[N],ncnt[N]={0};
void eluer(int n){
	for(ll i=2;i<=n;i++){
		if(!vis[i]){
			prime[++primecnt]=i;
			for(ll j=i*i;j<=n;j+=i){
				vis[j]=1;
			}
		}
	}
}
int main(){
    //freopen("D:\\in.txt","r",stdin);
    //freopen("D:\\out.txt","w",stdout);
	int n; cin>>n;
	eluer(sqrt(n)+1);
//	rep(i,1,primecnt){
//		rep(j,1,n){
//			if(!b[j]){
//				b[j]=1;
//				ncnt[i]++;
//			}
//		}
//	}
	rep(i,1,primecnt){
		cout<<"B "<<prime[i]<<endl;
		cout.flush();
		int tmp; cin>>tmp;
	}
	int ans=1;
	rep(i,1,primecnt){
		int now=prime[i];
		while(1){
			cout<<"A "<<now<<endl;
			cout.flush();
			int x; cin>>x;
			if(x){
				now*=prime[i];
				ans*=prime[i];
			}
			else break;
		}
	}
	cout<<"C "<<ans<<endl;
	cout.flush();
    return 0;
}


#include<bits/stdc++.h>
#define rep(i,x,y) for(auto i=(x);i<=(y);++i)
#define dep(i,x,y) for(auto i=(x);i>=(y);--i)
#define fr first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,ll>pil;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;
const int N=1e5+10;
const int inf=1e9;
const int mo=998244353;
bool b[N];
int prime[N],primecnt=0,vis[N],ncnt[N]={0};
void eluer(int n){
	for(ll i=2;i<=n;i++){
		if(!vis[i]){
			prime[++primecnt]=i;
			for(ll j=i*i;j<=n;j+=i){
				vis[j]=1;
			}
		}
	}
}
int main(){
    //freopen("D:\\in.txt","r",stdin);
    //freopen("D:\\out.txt","w",stdout);
	int n; cin>>n;
	eluer(n);
//	rep(i,1,primecnt){
//		rep(j,1,n){
//			if(!b[j]){
//				b[j]=1;
//				ncnt[i]++;
//			}
//		}
//	}
	rep(i,1,min(170,primecnt)){
		cout<<"B "<<prime[i]<<endl;
		cout.flush();
		int tmp; cin>>tmp;
	}
	int ans=1;
	rep(i,1,primecnt){
		int now=prime[i];
		while(1){
			cout<<"A "<<now<<endl;
			cout.flush();
			int x; cin>>x;
			if(x){
				now*=prime[i];
				ans*=prime[i];
			}
			else break;
		}
	}
	if(primecnt>170){
		int l=171,r=primecnt,pdt=r-l+1;
		while(l<=r){
			int mid=l+r>>1;
			rep(i,l,mid){
				pdt--;
				cout<<"B "<<prime[i]<<endl;
				cout.flush();
				int x; cin>>x;
			}
			cout<<"A 1"<<endl;
			cout.flush();
			int x; cin>>x;
			if(x==pdt){
				l=mid+1;
			}
			else{
				rep(i,l,mid){
					cout<<"A "<<prime[i]<<endl;
					cout.flush();
					int x; cin>>x;
					if(x) {
						ans*=prime[i];
						break;
					}
				}
				break;
			}
		}
	}
	cout<<"C "<<ans<<endl;
	cout.flush();
    return 0;
}


#include<bits/stdc++.h>
#define rep(i,x,y) for(auto i=(x);i<=(y);++i)
#define dep(i,x,y) for(auto i=(x);i>=(y);--i)
#define fr first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,ll>pil;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;
const int N=1e5+10;
const int inf=1e9;
const int mo=998244353;
bool b[N];
int prime[N],primecnt=0,vis[N],ncnt[N]={0};
void eluer(int n){
	for(ll i=2;i<=n;i++){
		if(!vis[i]){
			prime[++primecnt]=i;
			for(ll j=i*i;j<=n;j+=i){
				vis[j]=1;
			}
		}
	}
}
int main(){
    //freopen("D:\\in.txt","r",stdin);
    //freopen("D:\\out.txt","w",stdout);
	int n; cin>>n;
	eluer(n);
//	rep(i,1,primecnt){
//		rep(j,1,n){
//			if(!b[j]){
//				b[j]=1;
//				ncnt[i]++;
//			}
//		}
//	}
	rep(i,1,min(170,primecnt)){
		cout<<"B "<<prime[i]<<endl;
		cout.flush();
		int tmp; cin>>tmp;
	}
	int ans=1;
	rep(i,1,min(170,primecnt)){
		int now=prime[i];
		while(now<=n){
			cout<<"A "<<now<<endl;
			cout.flush();
			int x; cin>>x;
			if(x){
				now*=prime[i];
				ans*=prime[i];
			}
			else break;
		}
	}
	if(primecnt>170&&ans==1){
		int l=171,r=primecnt,pdt=r-l+1+1;
		while(l<=r){
			int mid=l+r>>1;
			rep(i,l,mid){
				pdt--;
				cout<<"B "<<prime[i]<<endl;
				cout.flush();
				int x; cin>>x;
			}
			cout<<"A 1"<<endl;
			cout.flush();
			int x; cin>>x;
			if(x==pdt){
				l=mid+1;
			}
			else{
				rep(i,l,mid){
					cout<<"A "<<prime[i]<<endl;
					cout.flush();
					int x; cin>>x;
					if(x) {
						ans*=prime[i];
						break;
					}
				}
				break;
			}
		}
	}
	else if(primecnt>170){
		rep(i,171,primecnt){
			cout<<"A "<<prime[i]<<endl;
			cout.flush();
			int x; cin>>x;
			if(x>=2){
				ans*=prime[i]; break;
			}
		}
	}
	cout<<"C "<<ans<<endl;
	cout.flush();
    return 0;
}


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int max,min,count=0,temp;
        max=min=sc.nextInt();
        for(int i=1;i<n;i++)
        {
            temp=sc.nextInt();
            if (temp > max || temp < min) count++;
            max = temp > max ? temp : max;
            min = temp < min ? temp : min;
        }
        System.out.print(count);
    }
}


import java.util.*;
public class Main {
    static Scanner in=new Scanner(System.in);
    public static void main(String[] args)
    {
        int n=in.nextInt();
        int count=0,min=0,max=0;
        int[] arr=new int[n];
        for(int i=0;i<n;i++)
        {
            arr[i]=in.nextInt();
            if(i==0)
            {
                min=max=arr[i];
            }
            else{
                if(arr[i]>max)
                {
                    max=arr[i];
                    count++;
                }
                if(arr[i]<min)
                {
                    min=arr[i];
                    count++;
                }
            }
        }

        System.out.print(count);
    }

}


import java.util.Scanner;

public class I_love_Username {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int array[] = new int[n];
        for (int i = 0; i < n; i++) {
            int ptos = in.nextInt();
            array[i] = ptos;
        }
        int count = 0;
        int mayor = array[0];
        for (int i = 0; i < array.length; i++) {
            if (mayor < array[i]) {
                mayor = array[i];
                count++;
            }
        }
        int menor = array[0];
        for (int i = 0; i < array.length; i++) {
            if (menor > array[i]) {
                menor = array[i];
                count++;
            }
        }
        System.out.println(count);
    }
}


import java.util.Scanner;

public class Practica_3 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String numero=in.nextLine();
        String linea = in.nextLine();
        String a[] = linea.split(" +");
        int menor = Integer.parseInt(a[0]);
        int mayor = Integer.parseInt(a[0]);
        int contador = 0;
        for (int i = 1; i < a.length; i++) {
            if (mayor < Integer.parseInt(a[i])) {
                mayor = Integer.parseInt(a[i]);
                contador++;
            }
            if (menor > Integer.parseInt(a[i])) {
                menor = Integer.parseInt(a[i]);
                contador++;
            }
        }
        System.out.println(contador);
    }
}


import java.util.Scanner;

public class ILOVEUSERNAME {
public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int n=in.nextInt();
    int[] a = new int[n];
    int count=0;
    int localmax=0;
    int localmin=0;
    for(int i=0;i<n;i++){
            a[i]=in.nextInt();
                        if(i==0){
                            localmax=a[i];
                            localmin=a[i];
                        }
                        if(a[i]>localmax){
                            localmax=a[i];
                            count++;
                        }
                        if(a[i]<localmin){
                            localmin=a[i];
                            count++;
                        }
    }
    System.out.println(count);
}
}


/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int min = sc.nextInt();
		int max = min;
		int ans = 0;
		for(int i = 1; i < n; i++){
			int cur = sc.nextInt();
			if(cur < min){
				min = cur;
				ans++;
			}
			if(cur > max){
				max = cur;
				ans++;
			}
		}
		System.out.println(ans);
	}
}


import java.util.*;
public class games {
	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int[] array = new int[n];
		int numCount = 0;
		for (int i = 0; i < n; i++){
			array[i] = s.nextInt();
		}
		int max = array[0];
		int min = array[0];
		for(int i = 0; i < n; i++){
	  		if (array[i] > max){
	  			max = array[i];
	  			numCount++;
			  }
	  		if (array[i] < min){
	  		    min = array[i];
	  		    numCount++;
	  		}
	  }
		System.out.println(numCount);
	}
}


import java.util.*;
import java.lang.*;
import java.io.*;

public class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int min = 1;
		int max = 1;
		int res = 1;
		for(int i = 0; i < n; ++i){
			int a = sc.nextInt();
			if(min > a){
				min = a;
				++res;
			}
			if(max < a){
				max = a;
				++res;
			}
		}
		System.out.print(res);
	}
}


import java.util.*;
import java.lang.*;
import java.io.*;

public class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int min = sc.nextInt();
		int max = min;
		int res = 0;
		for(int i = 0; i < n-1; ++i){
			int a = sc.nextInt();
			if(min > a){
				min = a;
				++res;
			}
			if(max < a){
				max = a;
				++res;
			}
		}
		System.out.print(res);
	}
}


/**
 * @author Juan Sebastian Beltran Rojas
 * @mail jsbeltran.valhalla@gmail.com
 * @veredict No enviado
 * @problemId 155A
 * @problemName I_love_%username%
 * @judge http://www.codeforces.com
 * @category adhoc
 * @level easy
 * @date 7/9/2015
 **/
import java.io.*;
import java.util.*;

import static java.lang.Integer.*;
import static java.lang.Math.*;
public class CF155A {
	public static void main(String args[]) throws Throwable {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int N=parseInt(in.readLine().trim());
		StringTokenizer st=new StringTokenizer(in.readLine());
		int max=parseInt(st.nextToken()),min=max,s=0;
		for(int i=1;i<N;i++) {
			int a=parseInt(st.nextToken());
			if(a>max) {
				max=a;
				s++;
			}
			if(a<min) {
				min=a;
				s++;
			}
		}
		System.out.println(s);
	}
}


import java.util.Scanner;
public class love
{
 public static void main(String args[])
 {
  int n,i;
  int k=0;
  Scanner in=new Scanner(System.in);
  n=in.nextInt();
  int a[]=new int[10000];
  int max=a[0],min=a[0];
  for(i=1;i<=n;i++)
  {
   a[i]=in.nextInt();
  }
  for(i=1;i<=n;i++)
  {
    if(a[i]>max)
      {
        max=a[i];
       k++;
      }
     else if(a[i]<min)
     {
       min=a[i];
       k++;
     }
  }
  System.out.println(k);

}
}


import java.util.Scanner;
public class love
{
 public static void main(String args[])
 {
  int n,i;
  int k=-1;
  int max=Integer.MIN_VALUE,min=Integer.MAX_VALUE;
  Scanner in=new Scanner(System.in);
  n=in.nextInt();
  int a[]=new int[10000];
  for(i=1;i<=n;i++)
  {
   a[i]=in.nextInt();
  }
  for(i=1;i<=n;i++)
  {
    if(a[i]>max)
	{
	   max=a[i];
	    k++;
	}
   else if(a[i]<min)
     {
        min=a[i];
         k++;
     }
  }
  System.out.println(k);

}
}


import java.util.Scanner;
public class love
{
 public static void main(String args[])
 {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int[] a=new int[n];

        for (int i = 0; i < a.length; i++) {
            a[i]=in.nextInt();
        }
        int max=a[0],min=a[0];

        int count=0;
        for (int i = 1; i < a.length; i++) {
            if(a[i]>max){
                count++;
                max=a[i];

            }
            else if(a[i]<min){
                min=a[i];
                count++;

            }
        }
        System.out.println(count);

    }

}


import java.util.Scanner;
public class love
{
 public static void main(String args[])
 {
  int n,i;
  int k=0;
  Scanner in=new Scanner(System.in);
  n=in.nextInt();
  int a[]=new int[n];
  int max=a[0],min=a[0];
  for(i=0;i<a.length;i++)
  {
   a[i]=in.nextInt();
  }
  for(i=1;i<a.length;i++)
  {
    if(a[i]>max)
      {
        max=a[i];
       k++;
      }
     else if(a[i]<min)
     {
       min=a[i];
       k++;
     }
  }
  System.out.println(k);

}
}


import java.util.Scanner;
public class love
{
 public static void main(String args[])
 {
  int n,i;
  int k=0;
  Scanner in=new Scanner(System.in);
  n=in.nextInt();
  int a[]=new int[10000];
  for(i=1;i<=n;i++)
  {
   a[i]=in.nextInt();
  }
  for(i=1;i<=n;i++)
  {
    if(a[i]<=a[i+1])
        k++;
  }
  System.out.println(k);
}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class ProblemA {
	public static void main(String[] args) {
		InputReader in = new InputReader();
		PrintWriter out = new PrintWriter(System.out);

		new ProblemA().solve(in, out);

		out.close();
	}

	public void solve(InputReader in, PrintWriter out) {
		int n = in.nextInt();

		int a = in.nextInt();

		int max = a;
		int min = a;

		int res = 0;
		for (int i = 1; i < n; i++) {
			a = in.nextInt();

			if (a > max) {
				max = a;
				res++;
			}

			if (a < min) {
				min = a;
				res++;
			}
		}

		out.println(res);
	}

	static class InputReader {
		public BufferedReader br;
		public StringTokenizer st;

		public InputReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}


import java.util.Scanner;

public class chat {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int count = 0;
		int min = sc.nextInt();
		int max = min;

		for (int i = 0; i < n-1; i++) {
			int a = sc.nextInt();
			if (a > max) {
				max = a;
				count++;
			} else if (a < min) {
				min = a;
				count++;
			}

		}
		System.out.println(count);
	}

}


import java.util.Scanner;

public class chat {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		System.out.println(find(n, 0, 0));

	}
	public static int find(int n, int count, int iterationnum)
	{
		if(n == 1)
			return 1;

		count += n + iterationnum + find(n-1, count, ++iterationnum);

		return count;

	}

}


/*
 Author: Togrul Gasimov
 Mail: ttogrul30@gmail.com
 */

import java.util.Collection;
import java.util.Comparator;
import java.util.Locale;
import java.util.Scanner;
import java.util.Vector;
import java.util.Arrays;
import java.math.BigInteger;
import java.math.BigDecimal;
import java.util.List;
import java.util.Stack;

import javax.print.attribute.IntegerSyntax;

public class Main {

static double u(double x1,double y1,double x2,double y2){
return Math.sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)  );
}
static int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}

// static double PI=3.1415926535897932384626433832795;
 static int[] a= new int[1000000];
public static void main(String[] args) {
 Scanner scan = new Scanner(System.in);

  int n,max,ans=0,min;

  n=scan.nextInt();

  for(int i=1;i<=n;i++){
	  a[i]=scan.nextInt();
  }
  max=a[1]; min=a[1];

  for(int i=2;i<=n;i++){
	  if(a[i]>max){
		  ans++; max=a[i];
	  }
	  if(min>a[i]){
		  min=a[i]; ans++;
	  }
  }
  System.out.println(ans);
}
}


/*
 Author: Togrul Gasimov
 Mail: ttogrul30@gmail.com
 */

import java.util.Collection;
import java.util.Comparator;
import java.util.Locale;
import java.util.Scanner;
import java.util.Vector;
import java.util.Arrays;
import java.math.BigInteger;
import java.math.BigDecimal;
import java.util.List;
import java.util.Stack;

import javax.print.attribute.IntegerSyntax;

public class Main {

static double u(double x1,double y1,double x2,double y2){
return Math.sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)  );
}
static int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}

// static double PI=3.1415926535897932384626433832795;
 static int[] a= new int[1000000];
public static void main(String[] args) {
 Scanner scan = new Scanner(System.in);

  int n,max,ans=1;

  n=scan.nextInt();

  for(int i=1;i<=n;i++){
	  a[i]=scan.nextInt();
  }
  max=a[1];

  for(int i=2;i<=n;i++){
	  if(a[i]>max){
		  ans++; max=a[i];
	  }
  }
  System.out.println(ans);
}
}


import java.util.Scanner;

public class A_109 {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();
		int k = scanner.nextInt();
		int min = k,max = k,sum=0;
		for(int i=1; i<n; i++){
			k = scanner.nextInt();
			if( k>max ) {sum++;max=k;}
			if( k<min ) {sum++;min=k;}
		}
		System.out.println(sum);
	}
}


import java.util.Scanner ;
public class Main{
public static void main(String[] args)
{
int x , first , max , min , count ;
Scanner in = new Scanner(System.in) ;
x = in.nextInt() ;
first = in.nextInt() ;
max = first ;
min = first ;
count = 0 ;

for ( int i = 0 ; i < x - 1 ; i++)
{
  first = in.nextInt() ;
  if ( first < min )
  {
    count++ ;
     min = first ;
   }
   if ( max < first)
   {
     count++ ;
     max = first ;
   }

}
System.out.println(count) ;
}
}


public class Main{
public static void main(String[] args)
{
int x , first , max , min , count ;
Scanner in = new Scanner(System.in) ;
x = in.nextInt() ;
first = in.nextInt() ;
max = first ;
min = first ;
count = 0 ;

for ( int i = 0 ; i < x - 1 ; i++)
{
  first = in.nextInt() ;
  if ( first < min )
  {
    count++ ;
     min = first ;
   }
   if ( max < first)
   {
     count++ ;
     max = first ;
   }

}
System.out.println(count) ;
}
}


import java.util.*;

public class Olesya {
	public static void main (String args[]) {
		Scanner in = new Scanner (System.in);
		int n = in.nextInt();
		int max = in.nextInt();
		int min = max;
		int amaze = 0;
		for (int i = 0; i < n - 1; i++) {
			int temp = in.nextInt();
			if (temp > max) {
				max = temp;
				amaze++;
			} else if (temp < min) {
				min = temp;
				amaze++;
			}
		}
		System.out.println (amaze);
	}
}


/*
 * To change this template, choose Tools | Templates
 * iand open the template in the editor.
 */
import java.io.*;
/**
 *
 * @author Elcot
 */
public class username
{
    public static void main(String args[])throws IOException
    {
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(in.readLine());
        int a[]=new int[1000];
        String s[]=in.readLine().split(" ");
        a[0]=Integer.parseInt(s[0]);
        int max=a[0];
        int count=1;
        for(int i=1;i<s.length;i++)

        {
            a[i]=Integer.parseInt(s[i]);
            if(a[i]>max)
            {
                max=a[i];
                count++;
            }
        }
        if(n==1)count=0;
    System.out.println(count);
    }

}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
import java.io.*;
/**
 *
 * @author student
 */
public class username
{
    public static void main(String args[])throws IOException
    {
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(in.readLine());
        String s[]=in.readLine().split(" ");
        int min=0,max=0;
        int count=0,x;
        for(int i=0;i<n;i++)
        {
            x=Integer.parseInt(s[i]);
            if(i==0)
            {
                min=max=x;
            }
            else
            {
                if(x>max)
                {
                    max=x;
                    count++;
                }
                if(x<min)
                {
                    min=x;
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}


/*
 * To change this template, choose Tools | Templates
 * iand open the template in the editor.
 */
import java.io.*;
/**
 *
 * @author Elcot
 */
public class ilove
{
    public static void main(String args[])throws IOException
    {
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(in.readLine());
        int a[]=new int[1000];
        String s[]=in.readLine().split(" ");
        a[0]=Integer.parseInt(s[0]);
        int max=a[0];
        int count=1;
        for(int i=1;i<s.length;i++)

        {
            a[i]=Integer.parseInt(s[i]);
            if(a[i]>max)
            {
                max=a[i];
                count++;
            }
        }
    System.out.println(count);
    }

}


//package practice;
import java.util.*;
public class CF109A {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] a=new int[n];
		for(int i=0;i<n;i++) a[i]=sc.nextInt();
		int min=a[0];
		int max=a[0];
		int count=0;
		for(int i=0;i<n;i++)
		{
			if(a[i]>max)
			{
				count++;
				max=a[i];
			} else if(a[i]<min)
			{
				count++;
				min=a[i];
			}
		}
		System.out.println(count);
	}

}


//package practice;
import java.util.*;
// hallo :P
public class CF109A {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] a=new int[n];
		for(int i=0;i<n;i++) a[i]=sc.nextInt();
		int min=a[0];
		int max=a[0];
		int count=0;
		for(int i=0;i<n;i++)
		{
			if(a[i]>max)
			{
				count++;
				max=a[i];
			} else if(a[i]<min)
			{
				count++;
				min=a[i];
			}
		}
		System.out.println(count);
	}

}


import java.util.*;
public class UserName{

public static void main(String[] rg){

Scanner scan=new Scanner(System.in);
int n=scan.nextInt();
int[] a=new int[n];
for(int i=0;i<n;i++)
a[i]=scan.nextInt();
int min=a[0],max=a[0],x=0;
for(int i=1;i<n;i++)
	{
		if(a[i]>max){

				max=a[i];++x;
				}
		else if(a[i] < min){
			min=a[i];++x;

				}

	}
System.out.println(x);

}

}


import java.util.Scanner;

public class ILovve {
    public static void main(String asd[])throws Exception
    {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int c=0;
        int a[]=new int[n];
        for(int i=0;i<n;i++)
        {
            a[i]=in.nextInt();
        }
        for(int i=1;i<n;i++)
        {
            int cc=0,d=0;
            for(int j=0;j<i;j++)
            {
                if(a[i]>a[j])
                    cc++;
                else if(a[i]<a[j])
                    d++;
            }
            if(cc==i || d==i)
                c++;
        }
        System.out.println(c);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class LoveUserName {

	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String str1=br.readLine();
		String str=br.readLine();
		String arr[]=str.split(" ");
		int min;
		int max=min=Integer.parseInt(arr[0]);
		int count=0;
		boolean ismin=false;
		boolean ismax=false;

		for(int i=1;i<arr.length;i++){
			int x= Integer.parseInt(arr[i]);

			if(x>max){

				max=x;
				if(i!=0){
					count++;}
			}else if(x<min){
				min=x;
				if(i!=0){
					count++;
				}
			}

		}
		System.out.println(count);

	}

}


import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Set;
import java.util.TreeSet;

public class Main
{
	public void foo()
	{
		MyScanner scan = new MyScanner();
		int n = scan.nextInt();
		int sum = 0;
		int a = scan.nextInt();
		int maxPoint = a;
		int minPoint = a;
		for(int i = 1;i < n;++i)
		{
			a = scan.nextInt();
			if(a > maxPoint)
			{
				maxPoint = a;
				++sum;
 			}
			else if(a < minPoint)
			{
				minPoint = a;
				++sum;
			}
		}
		System.out.println(sum);
	}

	public static void main(String[] args)
	{
		new Main().foo();
	}

	class MyScanner
	{
	    private byte[] buf = new byte[1024];
	    private int curChar;
	    private int numChars;
	    BufferedInputStream bis = new BufferedInputStream(System.in);

	    public int read()
	    {
	        if (-1 == numChars)
	        {
	        	throw new InputMismatchException();
	        }
	        if (curChar >= numChars)
	        {
	            curChar = 0;
	            try
	            {
	                numChars = bis.read(buf);
	            }
	            catch (IOException e)
	            {
	                throw new InputMismatchException();
	            }
	            if (numChars <= 0)
	            {
	            	return -1;
	            }
	        }
	        return buf[curChar++];
	    }

	    public int nextInt()
	    {
	        int c = read();
	        while (isSpaceChar(c))
	        {
	        	c = read();
	        }
	        int sgn = 1;
	        if (c == '-')
	        {
	            sgn = -1;
	            c = read();
	        }
	        int res = 0;
	        do
	        {
	            if (c < '0' || c > '9')
	            {
	            	throw new InputMismatchException();
	            }
	            res *= 10;
	            res += c - '0';
	            c = read();
	        } while (!isSpaceChar(c));
	        return res * sgn;
	    }

	    public long nextLong()
	    {
	    	int c = read();
	    	while (isSpaceChar(c))
	    	{
	    		c = read();
	    	}
	    	int sgn = 1;
	    	if (c == '-')
	    	{
	    		sgn = -1;
	    		c = read();
	    	}
	    	long res = 0;
	    	do
	    	{
	    		if (c < '0' || c > '9')
	    		{
	    			throw new InputMismatchException();
	    		}
	    		res *= 10;
	    		res += c - '0';
	    		c = read();
	    	} while (!isSpaceChar(c));
	    	return res * sgn;
	    }

	    public String next()
	    {
	        int c = read();
	        while (isSpaceChar(c))
	        {
	        	c = read();
	        }
	        StringBuilder res = new StringBuilder();
	        do
	        {
	            res.appendCodePoint(c);
	            c = read();
	        } while (!isSpaceChar(c));
	        return res.toString();
	    }

	    private boolean isSpaceChar(int c)
	    {
	        return ' ' == c || '\n' == c || '\r' == c || '\t' == c || -1 == c;
	    }
	}
}


#include <stdio.h>

int main() {

    int n, i, res=0;

    scanf("%d",&n);
    int a[n];

    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }

    int max=a[0];
    int mint=a[0];

    for(i=0;i<n;i++){
        if(a[i]>max){
            max=a[i];
            res++;
        }
        if(a[i]<mint){
           mint=a[i];
           res++;
        }
    }

    printf("%d\n", res);

    return 0;
}


#include <stdio.h>

int main() {

    int n, min, max, res=0, x;

    scanf("%d", &n);

    for(int i=1; i<=n; i++) {
        scanf("%d", &x);

        if(x > max) {
            res++;
            max = x;
        }

        if(x < min) {
            res++;
            min = x;
        }
    }

    printf("%d", res);

    return 0;
}


#include <stdio.h>

int main() {

    int n, min=0, max=0, res=0, x;

    scanf("%d", &n);

    for(int i=1; i<=n; i++) {
        scanf("%d", &x);

        if(n == 1) {
            break;
        }

        if(x > max) {
            res++;
            max = x;
        }

        if(x < min) {
            res++;
            min = x;
        }
    }

    printf("%d", res);

    return 0;
}


#include <stdio.h>

int main() {

    int n, min, max, res=0, x;

    scanf("%d", &n);

    for(int i=1; i<=n; i++) {
        scanf("%d", &x);

        if(x > max) {
            res++;
            max = x;
        }

        if(x < min) {
            res++;
            min = x;
        }
    }

    printf("%d\n", res);

    return 0;
}


#include <stdio.h>

int main() {

    int n, min=0, max=0, res=0, x;

    scanf("%d", &n);

    for(int i=1; i<=n; i++) {
        scanf("%d", &x);

        if(x > max) {
            res++;
            max = x;
        }

        if(x < min) {
            res++;
            min = x;
        }
    }

    printf("%d", res);

    return 0;
}


#include <iostream>

using namespace std;
int main()
{
    int arr[100];
    int dis[30];
    int n;
    int h=0;
    cin >> n;
    int mx,mn;
    cin >> arr[0];
    mx=mn=arr[0];
    for(int i=1;i<n;i++){
        cin >> arr[i];
        if(arr[i]>mx){
          dis[h]=arr[i];
          mx=arr[i];
          h++;
        }
       if(arr[i]<mn){
        dis[h]=arr[i];
          mn=arr[i];
          h++;
       }
    }
    mn=0;
    mn+=h;
    mn+=1;
    cout << mn << endl;
}


#include <iostream>

using namespace std;
int main()
{
    int arr[1000];
    int dis[999];
    int n;
    int h=0;
    cin >> n;
    int mx,mn;
    cin >> arr[0];
    mx=mn=arr[0];
    for(int i=1;i<n;i++){
        cin >> arr[i];
        if(arr[i]>mx){
          dis[h]=arr[i];
          mx=arr[i];
          h++;
        }
       if(arr[i]<mn){
        dis[h]=arr[i];
          mn=arr[i];
          h++;//
       }
    }
    mn=0;
    mn+=h;
    cout << mn << endl;
}


#include <iostream>

using namespace std;
int main()
{
    int arr[100];
    int dis[30];
    int n;
    int h=0;
    cin >> n;
    int mx,mn;
    cin >> arr[0];
    mx=mn=arr[0];
    for(int i=1;i<n;i++){
        cin >> arr[i];
        if(arr[i]>mx){
          dis[h]=arr[i];
          mx=arr[i];
          h++;
        }
       if(arr[i]<mn){
        dis[h]=arr[i];
          mn=arr[i];
          h++;
       }
    }
    mn=0;
    mn+=h;
    cout << mn << endl;
}


#include <iostream>

using namespace std;
int main()
{
    int arr[1000];
    int dis[999];
    int n;
    int h=0;
    cin >> n;
    int mx,mn;
    cin >> arr[0];
    mx=mn=arr[0];
    for(int i=1;i<n;i++){
        cin >> arr[i];
        if(arr[i]>mx){
          dis[h]=arr[i];
          mx=arr[i];
          h++;
        }
       if(arr[i]<mn){
        dis[h]=arr[i];
          mn=arr[i];
          h++;
       }
    }
    mn=0;
    mn+=h;
    cout << mn << endl;
}


#include <iostream>

using namespace std;
int main()
{
    int arr[100];
    int dis[30];
    int n;
    int h=0;
    cin >> n;
    int mx,mn;
    cin >> arr[0];
    mx=mn=arr[0];
    for(int i=1;i<n;i++){
        cin >> arr[i];
        if(arr[i]>mx){
          dis[h]=arr[i];
          mx=arr[i];
          h++;
        }
       if(arr[i]<mn){
        dis[h]=arr[i];
          mn=arr[i];
          h++;
       }
    }
    mn=0;
    for(int j=0;j<h;j++){
        mn+=dis[j];
    }
    cout << mn << endl;
}


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

int main(int argc, char *argv[])
{

  long long int t, n,m=0,k=0,i,min,max;

  cin>>n;
  long long int a[n];
  cin>>a[0];
  min=a[0];
  max=a[0];
  for(i=1;i<n;i++){

    cin>>a[i];
    if(min>=a[i]){

      min=a[i];
    }

    }

    for(i=0;i<n;i++){

    /*  if(a[i]==min){

        m++;
      }*/
       if((max<a[i] || a[i]==min) && (n!=1)){

        m++;
        max=a[i];
        //cout<<m;
      }

    }

    cout<<m;

  }


#include<iostream>

using namespace std;

int main(int argc, char *argv[])
{

  long long int t, n,m=0,k=0,i,min,max;

  cin>>n;
  long long int a[n];
  cin>>a[0];
 // min=a[0];
  max=a[0];
  for(i=1;i<n;i++){

    cin>>a[i];
        min=a[i];
    if(min>=a[i]){

             min=a[i];
    }

    }

    for(i=0;i<n;i++){

    /*  if(a[i]==min){

        m++;
      }*/
       if((max<a[i] || a[i]==min)){

        m++;
        max=a[i];
        //cout<<m;
      }

    }

    cout<<m;

  }


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

int main(int argc, char *argv[])
{

  long long int t, n,m=0,k=0,i,min,max;

  cin>>n;
  long long int a[n];
  cin>>a[0];
 // min=a[0];
  max=a[0];
  for(i=1;i<n;i++){

    cin>>a[i];
        min=a[i];
    if(min>=a[i]){

             min=a[i];
    }

    }

    for(i=0;i<n;i++){

    /*  if(a[i]==min){

        m++;
      }*/
       if((max<a[i] || a[i]==min)){

        m++;
        max=a[i];
        //cout<<m;
      }

    }

    cout<<m;

  }


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

int main(int argc, char *argv[])
{

  long long int t, n,m=0,k=0,i,min,max;

  cin>>n;
  long long int a[n];
  cin>>a[0];
  min=a[0];
  max=a[0];
  for(i=1;i<n;i++){

    cin>>a[i];
    if(min>=a[i]){

      min=a[i];
    }

    }

    for(i=0;i<n;i++){

    /*  if(a[i]==min){

        m++;
      }*/
       if((max<a[i] || a[i]==min) && (max!=min)){

        m++;
        max=a[i];
        cout<<m;
      }

    }

    cout<<m;

  }


#include<iostream>

using namespace std;

int main(int argc, char *argv[])
{

 long long int t, n,m=0,k=0,i,min,max;

  cin>>n;
  long long int a[n];
  cin>>a[0];
    if(n>=2){
    cin>>a[1];
  min=a[1];}
  max=a[0];
  for(i=2;i<n;i++){

    cin>>a[i];
        //min=a[i];
    if(min>=a[i]){

             min=a[i];
    }

    }

    for(i=0;i<n;i++){

      if(max<a[i]){

       k++;
      }
    else   if((max<a[i] || a[i]==min)){

        m++;
        max=a[i];
        //cout<<m;
      }

    }
   if(k==n-1)
    {

    	cout<<k;}
    	else{
    cout<<m;
    	}

  }


#include<iostream>

using namespace std;

int main(int argc, char *argv[])
{

 long long int t, n,m=0,k=0,i,min,max;

  cin>>n;
  long long int a[n];
  cin>>a[0];
    if(n>=2){
    cin>>a[1];
  min=a[1];}
  max=a[0];
  for(i=2;i<n;i++){

    cin>>a[i];
        //min=a[i];
    if(min>=a[i]){

             min=a[i];
    }

    }

    for(i=0;i<n;i++){

      if(max>a[i]){

       k++;
      }
       if((max<a[i] || a[i]==min)){
        if(a[i]==min){
        	max=min;

        }
        m++;
        max=a[i];
        //cout<<m;
      }

    }
   if(k==n-1)
    {

    	cout<<k;}
    	else{
    cout<<m;
    	}

  }


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

int main(int argc, char *argv[])
{

  long long int t, n,m=0,k=0,i,min,max;

  cin>>n;
  long long int a[n];
  cin>>a[0];
  min=a[0];
  max=a[0];
  for(i=1;i<n;i++){

    cin>>a[i];
    if(min>=a[i]){

      min=a[i];
    }

    }
    if(n==1){
      cout<<"1";
    }
    else{
    for(i=0;i<n;i++){

    /*  if(a[i]==min){

        m++;
      }*/
       if(max<a[i] || a[i]==min){

        m++;
        max=a[i];

      }

    }

    }
    cout<<m;

  }


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,i,cnt=0;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    int maxx=a[0];
    int minn=a[0];
    for(i=0;i<n;i++){
        if(a[i]>maxx){
            maxx=a[i];
            cnt++;
        }
        if(a[i]<minn){
           minn=a[i];
           cnt++;
        }
    }
    printf("%d\n",cnt);

    return 0;
}


#include<iostream>

using namespace std;

int main(int argc, char *argv[])
{

 long long int t, n,m=0,k=0,i,min,max;

  cin>>n;
  long long int a[n];
  cin>>a[0];
    if(n>=2){
    cin>>a[1];
  min=a[1];}
  max=a[0];
  for(i=2;i<n;i++){

    cin>>a[i];
        //min=a[i];
    if(min>=a[i]){

             min=a[i];
    }

    }

    for(i=0;i<n;i++){

    /*  if(a[i]==min){

        m++;
      }*/
       if((max<a[i] || a[i]==min)){

        m++;
        max=a[i];
        //cout<<m;
      }

    }

    cout<<m;

  }


#include<iostream>

using namespace std;

int main(int argc, char *argv[])
{

 long long int t, n,m=0,k=0,i,min,max;

  cin>>n;
  long long int a[n];
  cin>>a[0];
    if(n>=2){
    cin>>a[1];
  min=a[1];}
  max=a[0];
  for(i=2;i<n;i++){

    cin>>a[i];
        //min=a[i];
    if(min>=a[i]){

             min=a[i];
    }

    }

    for(i=0;i<n;i++){

      if(max>a[i]){

       k++;
      }
       if((max<a[i] || a[i]==min)){

        m++;
        max=a[i];
        //cout<<m;
      }

    }
   if(k==n-1)
    {

    	cout<<k;}
    	else{
    cout<<m;
    	}

  }


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

int main(int argc, char *argv[])
{

  long long int t, n,m=0,k=0,i,min,max;

  cin>>n;
  long long int a[n];
  cin>>a[0];
  min=a[0];
  max=a[0];
  for(i=1;i<n;i++){

    cin>>a[i];
    if(min>=a[i]){

      min=a[i];
    }

    }

    for(i=0;i<n;i++){

    /*  if(a[i]==min){

        m++;
      }*/
       if(max<a[i] || a[i]==min){

        m++;
        max=a[i];

      }

    }

    cout<<m;

  }


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{

	vector<int>v;
	int count=0;
	int n;
	cin>>n;
	if(n>1)
	int count=1;
	int t;
	cin>>t;
	v.push_back(t);
	int t2;
	cin>>t2;
	v.push_back(t2);
	sort(v.begin(),v.end());

	for(int i=0;i<n-2;i++)
	{

		int x;
		cin>>x;
		if(x<v[0])
		{
			v[0]=x;
			count++;
		}
			if(x>v[1])
		{
			v[1]=x;
			count++;
		}
	}
	cout<<count;
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int count=1;
	vector<int>v;
	int n;
	cin>>n;
	int t;
	cin>>t;
	v.push_back(t);
	int t2;
	cin>>t2;
	v.push_back(t2);
	sort(v.begin(),v.end());

	for(int i=0;i<n-2;i++)
	{
		int x;
		cin>>x;
		if(x<v[0])
		{
			v[0]=x;
			count++;
		}
			if(x>v[1])
		{
			v[1]=x;
			count++;
		}
	}
	cout<<count;
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{

	vector<int>v;
	count=0;
	int n;
	cin>>n;
	if(n>1)
	int count=1;
	int t;
	cin>>t;
	v.push_back(t);
	int t2;
	cin>>t2;
	v.push_back(t2);
	sort(v.begin(),v.end());

	for(int i=0;i<n-2;i++)
	{

		int x;
		cin>>x;
		if(x<v[0])
		{
			v[0]=x;
			count++;
		}
			if(x>v[1])
		{
			v[1]=x;
			count++;
		}
	}
	cout<<count;
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{

	vector<int>v;
	int count=0;
	int n;
	cin>>n;
	int t;
	cin>>t;
	v.push_back(t);
	int t2;
	cin>>t2;
	v.push_back(t2);
	if(n>1&&t!=t2)
	{
	count=1;
    }
	sort(v.begin(),v.end());

	for(int i=0;i<n-2;i++)
	{

		int x;
		cin>>x;
		if(x<v[0])
		{
			v[0]=x;
			count++;
		}
			if(x>v[1])
		{
			v[1]=x;
			count++;
		}
	}
	cout<<count;
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{

	vector<int>v;
	int count=0;
	int n;
	cin>>n;
	if(n>1)
	{

	count=1;
    }
	int t;
	cin>>t;
	v.push_back(t);
	int t2;
	cin>>t2;
	v.push_back(t2);
	sort(v.begin(),v.end());

	for(int i=0;i<n-2;i++)
	{

		int x;
		cin>>x;
		if(x<v[0])
		{
			v[0]=x;
			count++;
		}
			if(x>v[1])
		{
			v[1]=x;
			count++;
		}
	}
	cout<<count;
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{

	vector<int>v;
	int count=0;
	int n;
	cin>>n;
	if(n>1)
	{

	count=1;
    }
	int t;
	cin>>t;
	v.push_back(t);
	int t2;
	cin>>t2;
	v.push_back(t2);
	if(n>1&&t!=t2)
	{
	count=1;
    }
	sort(v.begin(),v.end());

	for(int i=0;i<n-2;i++)
	{

		int x;
		cin>>x;
		if(x<v[0])
		{
			v[0]=x;
			count++;
		}
			if(x>v[1])
		{
			v[1]=x;
			count++;
		}
	}
	cout<<count;
}


#include<stdio.h>
int main(){
	int n,c=0,d=0,a[1010];
	int minn=10001,maxn=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(a[i]>maxn){
			maxn=a[i];
			c++;
		}
		if(a[i]<minn){
			minn=a[i];
			c++;
		}
	}
	printf("%d",c+d-2);
	return 0;
}


#include<iostream>
#include<cstdio>

using namespace std;

int main(){
	int n,i,ma,mi,sum;
	int a[1010];
	while(scanf("%d",&n)!=EOF){
		sum = 0;
		for(i=0;i<n;i++){
			scanf("%d",&a[i]);
		}
		ma=mi=a[0];
		for(i=1;i<n;i++){
			if(a[i]>ma){
				sum++;
				ma=a[i];
			}
			if(a[i]<mi){
				sum++;
				mi=a[i];
			}
		}
		printf("%d\n",sum);
	}
	return 0;
}


#include<stdio.h>
int main(){
	int n,c=0,d=0,a[100];
	int minn=10001,maxn=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(a[i]>maxn){
			maxn=a[i];
			c++;
		}
		if(a[i]<minn){
			minn=a[i];
			d++;
		}
	}
	printf("%d",c+d-2);
	return 0;
}


#include <iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;

int main()
{
	int i,n;
	int max,min;
	int sum;
	int a[1001];
	max=1;
	min=10000;
	sum=0;
	scanf("%d",&n);
	scanf("%d",&a[0]);
	max=a[0];
	min=a[0];
	for(i=1;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]>max)
		{
			max=a[i];
			sum++;
		}
		if(a[i]<min)
		{
			min=a[i];
			sum++;
		}

	}
	printf("%d\n",sum);

    return 0;
}


#include<stdio.h>
int main(){
	int n,c=0,d=0,a[1010];
	int minn=0,maxn=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	minn=maxn=a[0];
	for(int i=0;i<n;i++){
			if(a[i]>maxn){
			maxn=a[i];
			c++;
		}
		if(a[i]<minn){
			minn=a[i];
			c++;
		}
	}
	printf("%d",c);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int a , cnt = 0 , ans= 1 ;
    cin>> a;
    int arr[a];
    for(int i = 0 ; i< a; i ++)
    {
        cin>>arr[i];
    }
    cnt=arr[0];
    for(int i = 1 ;i < a; i ++)
    {
        if(arr[i]>cnt)
          {
            ans++;
        cnt=arr[i];
    }}
    cout<<ans;

}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int a , cnt = 0 , ans= 1 , mn = 1e9 , mx  =0;
    cin>> a;
    int arr[a];
    for(int i = 0 ; i< a; i ++)
    {
        cin>>arr[i];

    }
    mn = arr[0]  , mx = arr[0];
    for( int i = 1;i < a;i ++ ){
        if( arr[i] < mn )
            mn = arr[i] , cnt ++;
        if( arr[i] > mx )
            mx = arr[i] , cnt ++;
    }
    cout << cnt;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int a , cnt = 0 ;
    cin>> a;
    int arr[a];
    for(int i = 0 ; i< a; i ++)
    {
        cin>>arr[i];
    }
    for(int i = 0 ; i < a - 1; i ++)
    {
        if(arr[i]<arr[i+1])
            cnt++;
    }
    cout<<cnt;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int a , cnt = 0 ;
    cin>> a;
    int arr[a];
    for(int i = 0 ; i< a; i ++)
    {
        cin>>arr[i];
    }
    for(int i = 0 ; i < a - 1; i ++)
    {
        if(arr[i]<arr[i+1])
            cnt++;
    }
    cout<<cnt;
    if(cnt==0)
        cout<<1;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int a , cnt = 0 , ans= 1 ;
    cin>> a;
    int arr[a];
    for(int i = 0 ; i< a; i ++)
    {
        cin>>arr[i];
    }
    cnt=arr[0];
    if(a==1)
        cout<<0;
    else
    {
        for(int i = 1 ;i < a; i ++)
        {
            if(arr[i]>cnt)
              {
                ans++;
            cnt=arr[i];
        }

        }
        cout<<ans;
    }

}


#include <iostream>
using namespace std;

int main() {

	int n;
	int highest = 0;
	int highest_ct = 0;
	int lowest = 0;
	int lowest_ct = 0;
	cin >> n;

	for(int i = 0; i < n ; i++){
		int x;
		cin >> x;
		if(x > highest){
			highest_ct++;
			highest = x;
		}
		else if(x < lowest){
			lowest_ct++;
			lowest = x;
		}
	}
	if( highest_ct + lowest_ct <= 1){
		cout << 0 << endl;
	}
	else{
		cout << highest_ct + lowest_ct << endl;
	}

	return 0;
}


#include <iostream>
using namespace std;

int main() {

	int n;
	int highest_ct = 0;
	int lowest = 0;
	int lowest_ct = 0;
	cin >> n;

	int highest = 0;
	// cin >> highest ;

		if(n == 1){
			int x;
			cin >> x;
			cout << 0<< endl;
		}
		else{
			for(int i = 0; i < n ; i++){
				int x;
				cin >> x;

					if(x > highest){
						highest_ct++;
						highest = x;
					}
					else if(x < lowest){
						lowest_ct++;
						lowest = x;
					}

		}
		cout << highest_ct + lowest_ct << endl;
}

	return 0;
}


#include <iostream>
using namespace std;

int main() {
	int n,score;
	cin >> n >> score;
	int high = score;
	int low = score;
	int ans = 0;

	for(int i = 0; i< n-1 ; i++){
		int x;
		cin >> x;
		if(x > high){
			ans++;
			high = x;
		}
		else if(x < low){
			ans++;
			low = x;
		}
	}

	cout << ans << endl;
	return 0;
}


#include <iostream>
using namespace std;

int main() {

	int n;
	int highest_ct = 0;
	int lowest = 0;
	int lowest_ct = 0;
	cin >> n;

	int highest = 0;
	// cin >> highest ;
	for(int i = 0; i < n ; i++){
		int x;
		cin >> x;
		if(x > highest){
			if(i != 0){
				highest_ct++;
			}
			highest = x;
		}
		else if(x < lowest){
			if(i != 0){
				lowest_ct++;
			}
			lowest = x;
		}
	}

		cout << highest_ct + lowest_ct << endl;

	return 0;
}


#include <iostream>
using namespace std;

int main() {

	int n;
	int highest = 0;
	int highest_ct = 0;
	int lowest = 0;
	int lowest_ct = 0;
	cin >> n;

	for(int i = 0; i < n ; i++){
		int x;
		cin >> x;
		if(x > highest){
			highest_ct++;
			highest = x;
		}
		else if(x < lowest){
			lowest_ct++;
			lowest = x;
		}
	}
	if( highest_ct + lowest_ct <= 0){
		cout << 0 << endl;
	}
	else{
		cout << highest_ct + lowest_ct << endl;
	}

	return 0;
}


#include <iostream>
using namespace std;

int main() {

	int n;
	int highest = 0;
	int highest_ct = 0;
	int lowest = 0;
	int lowest_ct = 0;
	cin >> n;

	for(int i = 0; i < n ; i++){
		int x;
		cin >> x;
		if(x > highest){
			highest_ct++;
			highest = x;
		}
		else if(x < lowest){
			lowest_ct++;
			lowest = x;
		}
	}

	cout << highest_ct + lowest_ct << endl;

	return 0;
}


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

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    int mx = -1, mn = 1000000, ans = -2;
    for(int i = 1; i <= n; i ++) {
        int x;
        cin >> x;
        if(x > mx) ans ++, mx = x;
        if(x < mn) ans ++, mn = x;
    }
    cout << ans << endl;
}


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

using ll = long long;
int n;

int main() {
    scanf("%d", &n);
    int ans = 0, x;
    int mn = 0x3f3f3f3f, mx = 0;
    for (int i = 1; i <= n; i ++) {
        scanf("%d", &x);
        if (i > 1 && (x < mn || x > mx)) ans ++;
        mn = min(mn, x);
        mx = max(mx, x);
    }
    printf("%d\n", ans);
	return 0;
}


    #include <bits/stdc++.h>
using namespace std;
#define N 1005
int a[N];
int main(){
    int n;
    int sum = 0;
    cin>>n;
    for(int i = 0; i < n; i++)
        cin>>a[i];
    for(int i = 1; i < n; i++)
        if(a[i] > a[i - 1]) sum++;
    cout<<sum<<endl;
}


    #include <bits/stdc++.h>
using namespace std;
#define N 1005
int a[N];
int main(){
	int n;
	scanf("%d",&n);
	scanf("%d",&a[0]);
	int sum = 0;
	int mx = a[0],mn = a[0];
	for(int i = 1; i < n; i++){
		scanf("%d",a + i);
		if(a[i] > mx) {mx = a[i]; sum++;}
		if(a[i] < mn) {mn = a[i]; sum++;}
	}
	printf("%d\n",sum);
}


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

int main() {
	int n, x, mini, maxi;
	cin>>n>>x;
	mini = x, maxi = x;
	n --;
	int ans = 0;
	while (n --) {
		cin>>x;
		if (x < mini || x > maxi) ans ++;
		mini = min(mini, x);
		maxi = max(maxi, x);
	}
	cout<<ans;
}


    #include <bits/stdc++.h>
using namespace std;
#define N 1010
int a[N];
int main(){
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i ++) scanf("%d", &a[i]);
    int mina = a[0], maxa = a[0];
    int ans = 0;
    for(int i = 1; i < n; i ++){
        if(a[i] > maxa) maxa = a[i], ans ++;
        else if(a[i] < mina) mina = a[i], ans ++;
    }
    printf("%d", ans);
}


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

set<int> s;

int main() {
//	freopen("in.txt", "r", stdin);
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int n; cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) cin >> a[i];
	int cnt = 0;
	s.insert(a[0]);
	for (int i = 1; i < n; i++) {
		if(a[i] > *s.rbegin() || a[i] < *s.begin()) cnt++;
		s.insert(a[i]);
	}
	cout << cnt << endl;
	return 0;
}


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

int nxt[30], prv[30];

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    int mx = -1, ans = 0;
    for(int i = 1; i <= n; i ++) {
            int x;
        cin >> x;
        if(x > mx) ans ++, mx =x;
    }
    cout << ans << endl;
}


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

#define N 1010

int n, a[N];

int main() {
    scanf("%d", &n);
    int rlt = 0, mn = 1e9, mx = 0;
    for (int i = 1; i <= n; i ++) {
        int x;
        scanf("%d", &x);
        if (x < mn || x > mx) rlt ++;
        mn = min(mn, x), mx = max(mx, x);
    }
    printf("%d\n", rlt - 1);

    return 0;
}


    #include <bits/stdc++.h>

using namespace std;

int main() {
	int n, p, t, ma, mi,res = 0;
	scanf("%d", &n);
	scanf("%d", &p);
	ma = mi = p;
	for(int i = 1 ; i < n ; i ++){
		scanf("%d", &t);
		if(t > ma || t < mi)res ++;
		ma = max(ma, t);
		mi = min(mi, t);
	}
	printf("%d", res);
}


    #include <bits/stdc++.h>
using namespace std;
#define N 1005
int a[N];
int main(){
	int n;
	int sum = 0;
	cin>>n;
	for(int i = 0; i < n; i++)
		cin>>a[i];
	for(int i = 1; i < n; i++)
		if(a[i] > a[i - 1]) sum++;
	cout<<sum<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x=0,y=0,z=0,cnt=0,i;
    cin>>n;
    int arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    if(n==1)
    {
        cout<<cnt<<endl;
    }
    else
    {
        x=arr[0];
    if(x<arr[1])
    {
        y=arr[1];
        cnt++;
    }
    if(x>arr[1])
    {
        x=arr[1];
        y=arr[0];
        cnt++;
    }
    for(i=2;i<n;i++)
    {

        if(arr[i]<x)
        {
            cnt++;
            x=arr[i];
        }
        if(arr[i]>y)
        {
            cnt++;
            y=arr[i];
        }

    }
    cout<<cnt<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x=0,y=0,z=0,cnt=0,i,c=1;
    cin>>n;
    int arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    if(n==1)
    {
        cnt=0;
    }
    else
    {
        x=arr[0];
        for(i=c;i<n;i++)
        {
            if(x<arr[i])
        {
            y=arr[i];
            cnt++;
            break;
        }
        if(x>arr[i])
        {
            x=arr[i];
            y=arr[0];
            cnt++;
            break;
        }
        }
    }
    for(i=c+1;i<n;i++)
    {

        if(arr[i]<x)
        {
            cnt++;
            x=arr[i];
            //cout<<arr[i]<<" ";
        }
        if(arr[i]>y)
        {
            cnt++;
            y=arr[i];
            //cout<<arr[i]<<" ";
        }

    }
    cout<<cnt<<endl;
    }


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x=0,y=0,z=0,cnt=0,i,c=1;
    cin>>n;
    int arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    if(n==1)
    {
        cnt=0;
    }
    else
    {
        x=arr[0];
        for(i=c;i<n;i++)
        {
            if(x<arr[i])
        {
            y=arr[i];
            cnt++;
            break;
        }
        if(x>arr[i])
        {
            x=arr[i];
            y=arr[0];
            cnt++;
            break;
        }
        }
    }
    for(i=i;i<n;i++)
    {

        if(arr[i]<x)
        {
            cnt++;
            x=arr[i];
            //cout<<arr[i]<<" ";
        }
        if(arr[i]>y)
        {
            cnt++;
            y=arr[i];
            //cout<<arr[i]<<" ";
        }

    }
    cout<<cnt<<endl;
    }


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x=0,y=0,z=0,cnt=0,i;
    cin>>n;
    int arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    if(n==1)
    {
        cout<<cnt<<endl;
    }
    else
    {
        x=arr[0];
    if(arr[0]==arr[1])
    {
        cnt=-1;
    }
    if(x<arr[1])
    {
        y=arr[1];
        cnt++;
    }
    if(x>arr[1])
    {
        x=arr[1];
        y=arr[0];
        cnt++;
    }
    for(i=2;i<n;i++)
    {

        if(arr[i]<x)
        {
            cnt++;
            x=arr[i];
        }
        if(arr[i]>y)
        {
            cnt++;
            y=arr[i];
        }

    }
    cout<<cnt<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x=0,y=0,z=0,cnt=0,i,c=1;
    cin>>n;
    int arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    if(n==1)
    {
        cout<<cnt<<endl;
    }
    else
    {
        x=arr[0];
        for(i=c;i<n;i++)
        {
            if(x<arr[i])
        {
            y=arr[i];
            cnt++;
            break;
        }
        if(x>arr[i])
        {
            x=arr[i];
            y=arr[0];
            cnt++;
            break;
        }
        }
    }
    for(i=c+1;i<n;i++)
    {

        if(arr[i]<x)
        {
            cnt++;
            x=arr[i];
            //cout<<arr[i]<<" ";
        }
        if(arr[i]>y)
        {
            cnt++;
            y=arr[i];
            //cout<<arr[i]<<" ";
        }

    }
    cout<<cnt<<endl;
    }


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x=0,y=0,z=0,cnt=1,i;
    cin>>n;
    int arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    x=arr[0];
    if(x<arr[1])
    {
        y=arr[1];
    }
    if(x>arr[1])
    {
        x=arr[1];
        y=arr[0];
    }
    for(i=2;i<n;i++)
    {

        if(arr[i]<x)
        {
            cnt++;
            x=arr[i];
        }
        if(arr[i]>y)
        {
            cnt++;
            y=arr[i];
        }

    }
    cout<<cnt<<endl;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,i,cnt=0;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    int maxx=a[0];
    int minn=a[0];
    for(i=0;i<n;i++){
        if(a[i]>maxx){
            maxx=a[i];
            cnt++;
        }
        if(a[i]<minn){
           minn=a[i];
           cnt++;
        }
    }
    printf("%d\n",cnt);

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,t,i=0,j=1,c=0;
    int ara[10000];
    cin>>t;

    for(a=0; a<t; a++)
    {
        cin>>ara[a];
    }

    while(ara[i]==ara[j] && j<t)
        {
            i++;
            j++;
        }

    if(ara[j]<ara[i])
    {
        for(i,j; j<t; i++,j++)
        {
            if(ara[j]<=ara[i])
            {
                c++;
            }

        }
    }
    else if(ara[j]>ara[i])
    {
        for(i,j; j<t; i++,j++)
        {
            if(ara[j]>=ara[i])
            {
                c++;
            }

        }
    }

    cout<<c<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,t,i,j,c=0;
    int ara[10000];
    cin>>t;

    for(a=0;a<t;a++)
    {
        cin>>ara[a];
    }
    for(i=0,j=1;j<t;i++,j++)
    {
        if(ara[j]>ara[i])
        {
            c++;
        }

    }
    cout<<c<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,t,i,j,c=0;
    int ara[10000];
    cin>>t;

    for(a=0;a<t;a++)
    {
        cin>>ara[a];
    }
    for(i=0,j=1;j<t;i++,j++)
    {
        if(ara[j]>ara[i])
        {
            c++;
        }

    }

    if(t==2)
    {
        c=1;
    }

    cout<<c<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,t,i=0,j=1,c=0;
    int ara[10000];
    cin>>t;

    for(a=0; a<t; a++)
    {
        cin>>ara[a];
    }

    while(ara[i]==ara[j] && j<t)
        {
            i++;
            j++;
        }

    if(ara[j]<ara[i])
    {
        for(i,j; j<t; i++,j++)
        {
            if(ara[j]<ara[i])
            {
                c++;
            }

        }
    }
    else if(ara[j]>ara[i])
    {
        for(i,j; j<t; i++,j++)
        {
            if(ara[j]>ara[i])
            {
                c++;
            }

        }
    }

    cout<<c<<endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

const int MAXN = 2e5 + 5;

int a[MAXN],sum[MAXN];

int cnt[MAXN];
int t, n, k;

int mini[MAXN], maxi[MAXN];

int main() {
	cin >> t;
	while(t--) {
		int ans = 2147483647;
		cin >> n >> k;
		for(int i = 1; i <= n; i++) {
			cin >> a[i];
		}

		memset(mini, 0, sizeof mini);
		memset(maxi, 0, sizeof maxi);
		memset(cnt, 0, sizeof cnt);

		for(int i = 1; i <= (n >> 1); i++) {
			cnt[a[i] + a[n - i + 1]]++;
			mini[i] = min(a[i], a[n - i + 1]);
			maxi[i] = max(a[i], a[n - i + 1]) + k;
		}

		sort(mini + 1, mini + 1 + (n >> 1), greater<int>());
		sort(maxi + 1, maxi + 1 + (n >> 1));

		for(int i = 0; i <= (k << 1); i++) {
			int cur = (n >> 1) - cnt[i]; //先处理成有多少个a[j]+a[n - j + 1] != i
			int left = 1, right = (n >> 1);
			int res = 0;
			while(left <= right) {
				int mid = (left + right) >> 1;
				if(mini[mid] >= i) {
					res = mid;
					left = mid + 1;
				} else {
					right = mid - 1;
				}
			}
			cur += res;

			res = 0;
			left = 1, right = (n >> 1);
			while(left <= right) {
				int mid = (left + right) >> 1;
				if(maxi[mid] < i) {
					res = mid;
					left = mid + 1;
				} else {
					right = mid - 1;
				}
			}
			cur += res;
			ans = min(ans, cur);
		}
		cout << ans << endl;
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int a;
int ling[200005],yi[200005],zy[200005];
char a1[200005];
int main()
{
	cin>>a;
	for(int yui=1;yui<=a;yui++)
	{
		int head1=1,tail1=1,head=1,tail=1,ling1=0,y1=0,opi=0,zu=0;
	scanf("%d",&opi);
cin>>a1;

	memset(zy,0,sizeof(zy));
   memset(yi,0,sizeof(yi));
   memset(ling,0,sizeof(ling));
	for(int ki=0;ki<=opi-1;ki++)
	{
		char ki1;
		int he;

		ki1=a1[ki];

		he=ki1-'0';

		if(he==0)
		{

		if(yi[head1]==0)
		{
		ling1++;
		ling[tail]=ling1;
		zy[ki]=ling1;
			tail++;
		}
		if(yi[head1]!=0)
		{
			zy[ki]=yi[head1];
		ling[tail]=yi[head1];
		tail++;
		head1++;

		}
		}
		if(he==1)
		{
			if(ling[head]==0)
		{

	ling1++;
		yi[tail1]=ling1;
		zy[ki]=ling1;
			tail1++;

		}
		if(ling[head]!=0)
		{
			zy[ki]=ling[head];
		yi[tail1]=ling[head];
		tail1++;
		head++;

		}
		}
	}
	cout<<ling1<<endl;
	for(int y=0;y<=opi-1;y++)
	cout<<zy[y]<<" ";

	cout<<endl;

	}
}


#include<bits/stdc++.h>
using namespace std;
int t;
int n,k;
int a[20050];
int d[40050];
int sum;
int minn,maxn,ans;
int main(){
	scanf("%d",&t);
	while(t--){
		memset(a,0,sizeof(a));
		memset(d,0,sizeof(d));
		scanf("%d %d",&n,&k);
		for(int i=1;i<=n;i++){
			scanf("%d",&a[i]);
			if(i>n/2){
				sum=a[i]+a[n-i+1];
				minn=min(a[i],a[n-i+1]);
				maxn=sum-minn;

				d[2]=d[2]+2;
				d[minn+1]=d[minn+1]-1;

				d[maxn+k+1]=d[maxn+k+1]+1;
			//	d[2*k+1]=d[2*k+1]-2;

			//	d[minn+1]=d[minn+1]+1;
				d[sum]=d[sum]-1;

				d[sum+1]=d[sum+1]+1;
			//	d[maxn+k+1]=d[maxn+k+1]-1;

			}
		}
		ans=d[2];
		for(int i=3;i<=2*k;i++){
			d[i]=d[i]+d[i-1];
			ans=min(d[i],ans);
		}
		printf("%d\n",ans);
	}
}


#include<bits/stdc++.h>
using namespace std;
int t;
int n,k;
int a[20050];
int d[40050];
int sum;
int minn,maxn,ans;
int main(){
	scanf("%d",&t);
	while(t--){
		memset(a,0,sizeof(a));
		memset(d,0,sizeof(d));
		scanf("%d %d",&n,&k);
		for(int i=1;i<=n;i++){
			scanf("%d",&a[i]);
			if(i>n/2){
				sum=a[i]+a[n-i+1];
				minn=min(a[i],a[n-i+1]);
				maxn=sum-minn;

				d[2]=d[2]+2;
				d[minn+1]=d[minn+1]-2;

				d[maxn+k+1]=d[maxn+k+1]+2;
				d[2*k+1]=d[2*k+1]-2;

				d[minn+1]=d[minn+1]+1;
				d[sum]=d[sum]-1;

				d[sum+1]=d[sum+1]+1;
				d[maxn+k+1]=d[maxn+k+1]-1;

			}
		}
		ans=d[2];
		for(int i=3;i<=2*k;i++){
			d[i]=d[i]+d[i-1];
			ans=min(d[i],ans);
		}
		printf("%d\n",ans);
	}
}


#include<bits/stdc++.h>
using namespace std;
int t;
int n,k;
int a[20050];
int d[40050];
int sum;
int minn,maxn,ans;
int main(){
	scanf("%d",&t);
	while(t--){
		memset(a,0,sizeof(a));
		memset(d,0,(2*k+5)*sizeof(int));
		scanf("%d %d",&n,&k);
		for(int i=1;i<=n;i++){
			scanf("%d",&a[i]);
			if(i>n/2){
				sum=a[i]+a[n-i+1];
				minn=min(a[i],a[n-i+1]);
				maxn=sum-minn;

				d[2]=d[2]+2;
				d[minn+1]=d[minn+1]-1;

				d[maxn+k+1]=d[maxn+k+1]+1;
			//	d[2*k+1]=d[2*k+1]-2;

			//	d[minn+1]=d[minn+1]+1;
				d[sum]=d[sum]-1;

				d[sum+1]=d[sum+1]+1;
			//	d[maxn+k+1]=d[maxn+k+1]-1;
			}
		}
		ans=d[2];
		for(int i=3;i<=2*k;i++){
			d[i]=d[i]+d[i-1];
			ans=min(d[i],ans);
		}
		printf("%d\n",ans);
	}
}


#include<bits/stdc++.h>
using namespace std;
int t;
int n,k;
int a[20050];
int d[40050];
int sum;
int minn,maxn,ans;
int main(){
	scanf("%d",&t);
	while(t--){
	//	memset(a,0,sizeof(a));
		memset(d,0,(2*k+5)*sizeof(int));
		scanf("%d %d",&n,&k);
		for(int i=1;i<=n;i++){
			scanf("%d",&a[i]);
			if(i>n/2){
				sum=a[i]+a[n-i+1];
				minn=min(a[i],a[n-i+1]);
				maxn=sum-minn;

				d[2]=d[2]+2;
				d[minn+1]=d[minn+1]-1;

				d[maxn+k+1]=d[maxn+k+1]+1;
			//	d[2*k+1]=d[2*k+1]-2;

			//	d[minn+1]=d[minn+1]+1;
				d[sum]=d[sum]-1;

				d[sum+1]=d[sum+1]+1;
			//	d[maxn+k+1]=d[maxn+k+1]-1;
			}
		}
		ans=d[2];
		for(int i=3;i<=2*k;i++){
			d[i]=d[i]+d[i-1];
			ans=min(d[i],ans);
		}
		printf("%d\n",ans);
	}
}


#include<bits/stdc++.h>
using namespace std;
int t;
int n,k;
int a[200050];
int d[400050];
int sum;
int minn,maxn,ans;
int main(){
	scanf("%d",&t);
	while(t--){
	//	memset(a,0,sizeof(a));
		memset(d,0,(2*k+5)*sizeof(int));
		scanf("%d %d",&n,&k);
		for(int i=1;i<=n;i++){
			scanf("%d",&a[i]);
			if(i>n/2){
				sum=a[i]+a[n-i+1];
				minn=min(a[i],a[n-i+1]);
				maxn=sum-minn;

				d[2]=d[2]+2;
				d[minn+1]=d[minn+1]-1;

				d[maxn+k+1]=d[maxn+k+1]+1;
			//	d[2*k+1]=d[2*k+1]-2;

			//	d[minn+1]=d[minn+1]+1;
				d[sum]=d[sum]-1;

				d[sum+1]=d[sum+1]+1;
			//	d[maxn+k+1]=d[maxn+k+1]-1;
			}
		}
		ans=d[2];
		for(int i=3;i<=2*k;i++){
			d[i]=d[i]+d[i-1];
			ans=min(d[i],ans);
		}
		printf("%d\n",ans);
	}
}


#include<bits/stdc++.h>
using namespace std;int ar[200050],delta[400050]; //������鿪2*k�Ŀռ�
void solve()
{

    int n,k,sum,minn,maxn,ans;
    cin>>n>>k;
    memset(delta,0,(2*k+10)*sizeof(int)); //��ʼ����2*k���ɣ��Դ�

    for(int i=1;i<=n;i++)
    {

        cin>>ar[i];

        if(i>n/2)

        {

            sum=ar[i]+ar[n-i+1];

            minn=min(ar[i],ar[n-i+1]);

            maxn=sum-minn;

            delta[2]+=2;

            delta[minn+1]--;

            delta[maxn+k+1]++;

            delta[sum]--;

            delta[sum+1]++;

        }

    }

    ans=delta[2];

    for(int i=3;i<=2*k;i++)

    {

        delta[i]+=delta[i-1];

        ans=min(delta[i],ans);

    }

    cout<<ans<<'\n';

}

int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);cout.tie(0);

    int T;cin>>T;

    for(int t=1;t<=T;t++)

        solve();

    return 0;

}


# include <iostream>
# include <algorithm>
# include <cstring>
# include <math.h>
# include <stdio.h>
# include <vector>
# include <map>
using namespace std;
# define ll long long
const int maxn = 5e5+10;
int a[maxn];
int d[maxn];
int c[maxn];
void add(int l, int r, int  num){
	if(l > r)
		return;
	d[l] += num;
	d[r+1] -= num;
}
int main(){

	int t;
	cin >> t;
	while(t--){
		memset(d,0,sizeof(d));
		int n,k;
		cin >> n >> k;
		for(int i = 1; i <= n; i++){
			cin >> a[i];
		}
		for(int i = 1; i <= n/2; i++){
			 int mi = min(a[i], a[n - i + 1]);
			 int mx = max(a[i], a[n - i + 1]);
			 add(mi + 1, mx + k, 1); //�����������ֵĺͱ�������������֣�ֻ��Ҫ�ı�mi
			 add(mx + k + 1, 2 * k, 2); // ������������䣬�϶��������ֶ�Ҫ��
			 add(mi + mx, mi + mx, -1);  // ��ǰ������ֲ��ñ仯�����Եõ�����ôȥ��һ�����ۣ���Ϊ֮ǰ����
			 add(1, mi, 2); //�������ֶ���Ҫ���С��mi�ģ�����Ϊ2
		}
		int ans = 0x3f3f;
		for(int i = 1; i <= 2*k; i++){
			c[i] = c[i-1] + d[i];
			ans = min(ans,c[i]);
		}
		cout << ans << endl;
	}
	return 0;
}


# include <iostream>
# include <algorithm>
# include <cstring>
# include <math.h>
# include <stdio.h>
# include <vector>
# include <map>
using namespace std;
# define ll long long
const int maxn = 5e5+10;
int a[maxn];
int d[maxn];
int c[maxn];
void add(int l, int r, int  num){

	if(l > r)
		return;
	d[l] += num;
	d[r+1] -= num;

}
int main(){

	int t;
	cin >> t;
	while(t--){
		memset(d,0,sizeof(d));
		int n,k;
		cin >> n >> k;
		for(int i = 1; i <= n; i++){
			cin >> a[i];
		}
		for(int i = 1; i <= n/2; i++){
			int min1 = min(a[i] , a[n-i+1]);
			int max1 = max(a[i] , a[n-i+1]);
			add(min1+1, max1+k, 1);//һ���ӻ��߼�
			add(max1+k+1, 2*k, 2);//����������
			add(max1+min1, max1+min1, -1);
			add(1, min1, 2);
		}
		int ans = 0x3f3f3f3f;
		//cout << ans << endl;
		for(int i = 1; i <= 2*k; i++){
			c[i] = c[i-1] + d[i];
			ans = min(ans,c[i]);
		}
		cout << ans << endl;
	}
	return 0;
}


# include <iostream>
# include <algorithm>
# include <cstring>
# include <math.h>
# include <stdio.h>
# include <vector>
# include <map>
using namespace std;
# define ll long long
const int maxn = 5e5+10;
int a[maxn];
int d[maxn];
int c[maxn];
void add(int l, int r, int  num){
	if(l > r)
		return;
	d[l] += num;
	d[r+1] -= num;
}
int main(){

	int t;
	cin >> t;
	while(t--){
		int n,k;
		cin >> n >> k;
		memset(d,0,sizeof d[0] * (2 * k + 10));
		for(int i = 1; i <= n; i++){
			cin >> a[i];
		}
		for(int i = 1; i <= n/2; i++){
			int min1 = min(a[i] , a[n-i+1]);
			int max1 = max(a[i] , a[n-i+1]);
			add(min1+1, max1+k, 1);//һ���ӻ��߼�
			add(max1+k+1, 2*k, 2);//����������
			add(max1+min1, max1+min1, -1);
			add(1, min1, 2);
		}
		int ans = 0x3f3f;
		for(int i = 1; i <= 2*k; i++){
			c[i] = c[i-1] + d[i];
			ans = min(ans,c[i]);
		}
		cout << ans << endl;
	}
	return 0;
}