#include using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x,bool> M; bool win(vector V) { sort(V.begin(),V.end()); if(M.count(V)) return M[V]; bool w=false; int pre=1,i,j; FOR(i,V.size()) if(V[i]!=pre) { vector V2; FOR(j,V.size()) if(i!=j) V2.push_back(V[j]); int xx=V[i]; if((xx+1)/2>1) V2.push_back((xx+1)/2); if((xx+0)/2>1) V2.push_back(xx/2); if(win(V2)==false) w=true; V2.clear(); FOR(j,V.size()) if(i!=j) V2.push_back(V[j]); xx=V[i]; if((xx+2)/3>1) V2.push_back((xx+2)/3); if((xx+1)/3>1) V2.push_back((xx+1)/3); if((xx+0)/3>1) V2.push_back(xx/3); if(win(V2)==false) w=true; if(w) break; pre=V[i]; } return M[V]=w; } void solve() { int i,j,k,l,r,x,y; string s; cin>>N; vector V; V.push_back(N); if(win(V)) cout<<"A"<