int p[N], cnt;
bool vis[N + 1];
void x_x()
{
f(i, 2, N)
{
if (!vis[i])p[++cnt] = i;
for (int j = 1;p[j] <= N / i;j++)
{
vis[p[j] * i] = true;
if (i%p[j] == 0)break;
}
}
}
int query2(char c, int x)
{
printf("%c %d", c, x);
cout << endl;
int tmp;cin >> tmp;
return tmp;
}
int main()
{
int n = in();
x_x();
memset(vis, false, sizeof vis);
int num = (int)sqrt(n);
int idx1_ed = upper_bound(p + 1, p + 1 + cnt, num) - p;
idx1_ed--;
int idx2_ed = upper_bound(p + 1, p + 1 + cnt, n) - p;
idx2_ed--;
ll fin = 1;
f(i, 1, idx1_ed)
{
query2('B', p[i]);
for (int k = 1;k*p[i] <= n;k++)
if (!vis[k*p[i]])vis[k*p[i]] = true;
ll ans = p[i];
while (ans <= n)
{
int tmp=query2('A', ans);
if (tmp == 0)break;
ans *= p[i];
}
fin *= ans / p[i];
}
if (fin == 1)
{
int pre = query2('A', 1);
int img = 0;
int nk = idx2_ed - idx1_ed;
if (nk == 0)goto hh;
int per = (int)sqrt(nk);
int avg = nk / per;
int num_kuai = per + 1;
int pre_idx = idx1_ed + 1;
f(j, 1, num_kuai)
{
f(i, pre_idx, min(pre_idx + avg, idx2_ed))
{
query2('B', p[i]);
for (int k = 1;k*p[i] <= n;k++)
{
if (!vis[k*p[i]])
{
img++;
vis[k*p[i]] = true;
}
}
}
int remain = query2('A', 1);
int fact = pre - remain;
if (fact != img)
{
f(i, pre_idx, min(pre_idx + avg, idx2_ed))
{
if (query2('A', p[i]))
{
fin *= p[i];
goto hh;
}
}
}
pre_idx = min(pre_idx + avg, idx2_ed) + 1;
}
}
else
{
int top = n / fin;
if (top == 1)goto hh;
int idx3_ed = upper_bound(p + 1, p + 1 + cnt, top) - p;
idx3_ed--;
f(i, idx1_ed + 1, idx3_ed)
{
int img = 0;
for (int k = 1;k*p[i] <= n;k++)
{
if (!vis[k*p[i]])
{
img++;
vis[k*p[i]] = true;
}
}
if (img != query2('B', p[i]))
{
fin *= p[i];
goto hh;
}
}
}
hh:
printf("C %d\n", fin);
return 0;
}