const int N = 1e6 + 50;
bool vis[N];
vector<int> primes;
void init() {
for (int i = 2; i < N; ++i) {
if (!vis[i]) primes.push_back(i);
for (int v : primes) {
if (v * i >= N) break;
vis[v * i] = true;
if (i % v == 0) break;
}
}
}
bool vis[N];
int phi[N], minFactor[N], plist[N / 10];
void initPrime() {
cnt = 0;
phi[1] = 1;
int x;
for (int i = 2; i < N; i++) {
if (!vis[i]) {
plist[cnt++] = i;
phi[i] = i - 1;
minFactor[i] = i;
}
for (int k = 0; k < cnt && plist[k] * i < N; k++) {
x = plist[k] * i;
vis[x] = true;
minFactor[x] = plist[k];
if (i % plist[k] == 0) {
phi[x] = phi[i] * plist[k];
break;
} else {
phi[x] = phi[i] * (plist[k] - 1);
}
}
}
}