#include using namespace std; #if __has_include() #include using namespace atcoder; using mint = modint998244353; #endif using ll = long long; using ld = long double; using ull = unsigned long long; #define endl "\n" typedef pair Pii; #define REP(i, n) for (int i = 0; i < (n)a; ++i) #define REP3(i, m, n) for (int i = (m); (i) < int(n); ++ (i)) #define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++) #define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define ALL(x) begin(x), end(x) #define PB push_back #define rrep(i,a,b) for(int i=a;i>=b;i--) #define fore(i,a) for(auto &i:a) #define all(s) (s).begin(),(s).end() #define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i) #define drep(i, n) drep2(i, n, 0) #define rever(vec) reverse(vec.begin(), vec.end()) #define sor(vec) sort(vec.begin(), vec.end()) #define fi first #define se second #define pb push_back #define P pair #define PQminll priority_queue, greater> #define PQmaxll priority_queue,less> #define PQminP priority_queue, greater

> #define PQmaxP priority_queue,less

> #define NP next_permutation //typedef string::const_iterator State; //class ParseError {}; //const ll mod = 1000000009; const ll mod = 998244353; //const ll mod = 1000000007; const ll inf = 4100000000000000000ll; const ld eps = ld(0.000000001); const long double pi = 3.141592653589793; templatevoid vcin(vector &n){for(int i=0;i>n[i];} templatevoid vcin(vector &n,vector &m){for(int i=0;i>n[i]>>m[i];} templatevoid vcout(vector &n){for(int i=0;ivoid vcin(vector> &n){for(int i=0;i>n[i][j];}}} templatevoid vcout(vector> &n){for(int i=0;ivoid print(T a){cout<void print(pair a){cout<bool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b void ifmin(T t,T u){if(t>u){cout<<-1< void ifmax(T t,T u){if(t>u){cout<<-1<>=1;v>>=1;}else if(eu&&!ev){u>>=1;}else if(!eu&&ev){v>>=1;}else if(u>=v){u=(u-v)>>1;}else{ll tmp=u;u=(v-u)>>1;v=tmp;}}return !u?v<>= 1; } return ret; } vector divisor(ll x){ vector ans; for(ll i = 1; i * i <= x; i++){ if(x % i == 0) {ans.push_back(i); if(i*i!=x){ ans.push_back(x / ans[i]);}}}sor(ans); return ans; } ll pop(ll x){return __builtin_popcountll(x);} ll poplong(ll x){ll y=0;while(x){x/=2;y++;}return y;} void cincout() { ios::sync_with_stdio(false); std::cin.tie(nullptr); cout<< fixed << setprecision(20); } vector> split[18]; void Plus(ll x){ for(int i=17;i>=0;i--){ for(auto e:split[i]){ for(int j=i+x;j<=17;j+=x){ e.pb(x); split[j].pb(e); } } } } void init(){ split[0].pb({}); for(int i=1;i<=17;i++){ Plus(i); } } map,ll> grundy,seen; void memo(vector a){ if(seen[a]) return; seen[a]=1; map m; for(int i=0;i<=17;i++){ for(int j=0;j x=split[i][j]; if(x==a) continue; if(x.size()+1==a.size()){ rever(x); x.pb(0); rever(x); } if(x.size()==a.size()){ vector b=a; bool f=true; rever(b); b.pb(0); rever(b); for(int k=0;k>n; ll g=0; vector spf(100001,inf); for(ll i=2;i<=100000;i++){ for(ll j=i;j<=100000;j+=i) chmin(spf[j],i); } for(int i=0;i pri; ll x; cin>>x; while(x>1){ pri[spf[x]]++; x/=spf[x]; } vector a; for(auto e:pri){ if(e.fi==2){ if(e.se==1){ a.pb(1); } if(e.se==2){ a.pb(2); } if(e.se>=3){ a.pb(2); ll now=1; for(int j=2;j> gr; for(auto e:a){ map r; while(e>1){ r[spf[e]]++; e/=spf[e]; } for(auto f:r) gr[f.fi].pb(f.se); } ll sum=0; for(auto e:gr){ sor(e.se); memo(e.se); sum+=grundy[e.se]; // for(auto f:e.se) cout<