#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

const int maxn = 2e5 + 5;


int main(){
	int t,n;
	scanf("%d",&t);
	while(t--){
		scanf("%d",&n);
		
		if(n == 2){
			printf("1\n");
		}else if(n%2 == 0){
			printf("2\n");
		}else if(n == 1){
			printf("0\n");
		}else if(n == 3){
			printf("2\n");
		}else{
			printf("3\n");
		}
			
	}
	return 0;
		
}