#include <iostream>
using namespace std;
typedef unsigned long long ull;
const int N = 1e6+10,P=1e9+7 ;
int n, m,len=1,z=0;
int a[110],dist[N];
bool st[N];
int dx[]= {1,-1,2};
int main()
{
int x,y,i,j,t;
cin>>t;
while(t--)
{
cin>>n;
int sum=0,cnt=n;
for(i=2; i<=n/i; i++)
{
if(n%i==0)
{
cnt=cnt/i*(i-1);
while(n%i==0)
n=n/i;
}
}
if(n>1)
cnt=cnt/n*(n-1);
cout<<cnt<<endl;
}
return 0;
}