using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Solution {
public static void Main(String[] args) {
int t = Convert.ToInt32(Console.ReadLine());
for(int a0 = 0; a0 < t; a0++){
int n = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(NthPrime(n));
}
}
static long NthPrime(int n)
{
long i = 2;
long j = 1;
long prime = 0;
while(true)
{
if (j<n)
{
if (IsPrime(i))
{
prime = i;
j++;
}
i++;
}
else
{
break;
}
}
return prime;
}
static bool IsPrime(long n)
{
if(n%2==0 ) return false;
long l = 3;
while (l < n)
{
if (n % l == 0)
return false;
l++;
}
return true;
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYzsKdXNpbmcgU3lzdGVtLklPOwp1c2luZyBTeXN0ZW0uTGlucTsKY2xhc3MgU29sdXRpb24gewoKICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBNYWluKFN0cmluZ1tdIGFyZ3MpIHsKICAgICAgICBpbnQgdCA9IENvbnZlcnQuVG9JbnQzMihDb25zb2xlLlJlYWRMaW5lKCkpOwogICAgICAgIGZvcihpbnQgYTAgPSAwOyBhMCA8IHQ7IGEwKyspewogICAgICAgICAgICBpbnQgbiA9IENvbnZlcnQuVG9JbnQzMihDb25zb2xlLlJlYWRMaW5lKCkpOwogICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZShOdGhQcmltZShuKSk7CiAgICAgICAgfQogICAgfQogICAgCiAgICBzdGF0aWMgbG9uZyBOdGhQcmltZShpbnQgbikKICAgIHsKICAgICAgICBsb25nIGkgPSAyOwogICAgICAgIGxvbmcgaiA9IDE7CiAgICAgICAgbG9uZyBwcmltZSA9IDA7CiAgICAgICAgd2hpbGUodHJ1ZSkKICAgICAgICB7CiAgICAgICAgICAgIGlmIChqPG4pCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGlmIChJc1ByaW1lKGkpKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIHByaW1lID0gaTsKICAgICAgICAgICAgICAgICAgICBqKys7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpKys7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICAKICAgICAgICByZXR1cm4gcHJpbWU7CiAgICB9CiAgICBzdGF0aWMgYm9vbCBJc1ByaW1lKGxvbmcgbikKICAgIHsKICAgICAgICBpZihuJTI9PTAgKSByZXR1cm4gZmFsc2U7CiAgICAgICAgbG9uZyBsID0gMzsKICAgICAgICB3aGlsZSAobCA8IG4pCiAgICAgICAgewogICAgICAgICAgICBpZiAobiAlIGwgPT0gMCkKICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgbCsrOwogICAgICAgIH0KICAgICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KfQ==