#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define N (1000000000+7) //#define N 998244353 #define INF 1e16 typedef long long ll; typedef pair P; typedef pair Q; const int inf = (int)1e9; ll gcd(ll a, ll b) { if (b > a) { ll tmp = b; b = a; a = tmp; } if (a%b == 0)return b; else return gcd(b, a%b); } bool prime[5000010]; void furui() { int i = 2; while (i <= 5000000) { int j = 2; while (j*j <= i && !prime[i]) { if (i%j == 0) { prime[i] = true; break; } else j++; } int z = 2; while (!prime[i]) { if (i*z <= 5000000) { prime[i*z] = true; z++; } else break; } i++; } } int main(void){ int T; scanf("%d",&T); furui(); for(int i=0;i