#include<iostream>
#include<ctype.h>
#include<stdio.h>
#include<string.h>
#include<string>
using namespace std;
unsigned long long factorial(int a)
{
unsigned long long factorial0 = 1;
for (int i = 2; i <= a; i++)factorial0 *= i;
return factorial0;
}
int main()
{
int n; scanf("%d", &n);
for (int j = 0; j < n; j++)
{
int a, temp; scanf("%d", &a);
unsigned long long all = factorial(a);
char s[20]; sprintf(s, "%lld", all); temp = strlen(s);
for (int i = strlen(s) - 1; i >= 0; i--)
if (s[i] == '0')temp = i;
for (int i = temp; s[i] != 0; i++)s[i] = '0';
if (temp != strlen(s))all = stoull(s) - 1;
cout << all << endl;
}
return 0;
}