template<typename T> inlinevoidread(T &x){ x = 0; T k = 1; char in = getchar(); while (!isdigit(in)) { if (in == '-') k = -1; in = getchar(); } while (isdigit(in)) x = x * 10 + in - '0', in = getchar(); x *= k; }
typedeflonglong ll;
const ll MOD = 1e9 + 7; constint N = 5e5 + 5;
int n, m; ll g[N], hash[N], pow[N];// g记录最小质因子,pow存进制的整数次幂 char s[N]; bool vis[N]; vector<ll> pri;
// 线性筛 inlinevoideuler(){ for (ll i = 2; i <= n; ++i) { if (!vis[i]) pri.push_back(i), g[i] = i; for (int j = 0; j < pri.size() && pri[j] * i <= n; ++j) { vis[pri[j]*i] = true, g[pri[j]*i] = pri[j]; if (i % pri[j] == 0) break; } } }