Runtime Error in test case 2 and 6

help me in handling test cases having large numbers

since constraints are large u need to use segmented sieve
theres a lecture by prateek bhaiya where segmented sieve is taught