// Arup Guha
// 9/11/2014
// Solution to Practice Problem: Prime

import java.util.*;
import java.io.*;

public class prime {
	
	public final static int MAX = 10000001;
	
	public static void main(String[] args) throws Exception {
		
		// Set up prime sieve.
		int[] isprime = new int[MAX];
		Arrays.fill(isprime, 1);
		isprime[0] = 0;
		isprime[1] = 0;
		
		// Easiest version of the prime sieve, good enough for this problem.
		for (int i=2; i<MAX; i++)
			for (int j=2*i; j<MAX; j+=i)
				isprime[j] = 0;
		
		
		// Set up to read input.
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		int numCases = Integer.parseInt(stdin.readLine().trim());
		
		// Process all cases.
		for (int i=0; i<numCases; i++) {
			int n = Integer.parseInt(stdin.readLine().trim());
			System.out.println(isprime[n]);
		}
		
	}
}