template<class T> inlinevoidqread(T &x) { x = 0; REG int t = 0; REG char ch = getchar(); while(!isdigit(ch)) t |= (ch == '-'), ch = getchar(); while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar(); x = t ? -x : x; }
inline ll qpow(ll a, ll x, ll mod) { REG ll s = a, t = a; --x; while(x) { if(x & 1) s = s * t % mod; t = t * t % mod; x >>= 1; } return s; }
inline ll phi(ll x) { REG ll res = x; for(REG ll i = 2; i * i <= x; i++) { if(x % i) continue; res = res / i * (i - 1); while(x % i == 0) x /= i; } if(x > 1) res = res / x * (x - 1); return res; }