/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
using namespace std;

int n, t;
int prime[32800], phi[32800], vis[32800];

void getphi(){
	phi[1] = 1;
	int tot = 0;
	for (int i = 2; i <= 32768; i++){
		if(!vis[i]){
			prime[++tot] = i;
			phi[i] = i - 1;
		}
		for (int j = 1; j <= tot && prime[j] * i <= 32768; j++){
			vis[i * prime[j]] = 1;
			if(i % prime[j] == 0){
				phi[i * prime[j]] = phi[i] * prime[j];
				break;
			}else{
				phi[i * prime[j]] = phi[i] * (prime[j] - 1);
			}
		}
	}
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	getphi();
	scanf("%d", &t);
	while(t--){
		scanf("%d", &n);
		printf("%d\n", phi[n]);
	}

	return 0;
}
/**/