// Arup Guha
// 7/8/2023
// Solution to 2023 SI@UCF CP Camp Contest #2 Problem: Pythagoras' Little Theorem

import java.util.*;

public class theorem {

	public static void main(String[] args) {
	
		// Pre-comp logs of factorials.
		double[] sumlogs = new double[100001];
		sumlogs[0] = 0; sumlogs[1] = 0;
		for (int i=2; i<=100000; i++)
			sumlogs[i] = sumlogs[i-1] + Math.log10(i);
			
		Scanner stdin = new Scanner(System.in);
		int nC = stdin.nextInt();
		
		// Process cases.
		for (int i=0; i<nC; i++) {
			int n = stdin.nextInt();
			
			// Get exponent to 10...so first digit.
			double left = sumlogs[n] - Math.floor(sumlogs[n]);
			
			// We just need to truncate this.
			double pow10 = Math.pow(10, left);
			System.out.println((int)pow10);
		}
	}
}