able to execute the code but testcase says timelimit exceeded please help me to minimize the code
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner scan =new Scanner(System.in);
int T=0;
int N=scan.nextInt();
for(int i=1;i<=N;i++)
{
T=scan.nextInt();
int paina=0;
int kinda=0;
int counter=0;
for( paina=2;paina<=1000;paina++)
{
boolean flag=true;
for( kinda=paina-1;kinda>=2;kinda--)
{
if(paina%kinda==0)
{
flag=false;
break;
}
}
if(flag==true)
{
counter++;
if(counter==T)
{
System.out.println(paina);
break;
}
}
}
}
}
}