#include <bits/stdc++.h>
using namespace std;
long long int phi[1000009], maxval = INT_MIN, minval = INT_MAX;
long long int cs[1000009], pos[1000009];
bitset<1000009> check, mp;
void sievephi(int n) {
  int i, j;
  for (i = 1; i <= n; i++) phi[i] = i, check[i] = 0;
  phi[1] = 1, check[1] = 1;
  for (i = 2; i <= n; i++) {
    if (!check[i]) {
      for (j = i; j <= n; j += i) {
        check[j] = 1;
        phi[j] -= phi[j] / i;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  sievephi(1000005);
  long long int t, i, j = 1, a, b, x, c, n;
  cin >> t;
  while (t--) {
    cin >> n;
    cout << phi[n] << '\n';
  }
  return 0;
}
