import java.util.;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t-- != 0) {
int n = sc.nextInt();
int[] ugly = new int[n];
ugly[0] = 1;
int i2 = 0, i3 = 0, i5 = 0;
int f2 = 2, f3 = 3, f5 = 5;
for(int i=1;i<n;i++){
int min = Math.min(Math.min(f2,f3),f5);
ugly[i] = min;
if(f2 == min)
f2 = 2ugly[++i2];
if(f3 == min)
f3 = 3ugly[++i3];
if(f5 == min)
f5 = 5ugly[++i5];
}
System.out.println(ugly[n-1]);
}
}
}