打表 不知道直接暴力會不會逾時
#include<iostream>
#include<cstdio>
#include<set>
#include<string>
#include<string.h>
#include<cstring>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<algorithm>
#include<sstream>
#include<utility>
#include<cmath>
#include<functional>
#define mt(a) memset(a,0,sizeof (a))
#define fl(a,b,c) fill(a,b,c)
#define SWAP(a,b,t) (t=a,a=b,b=t)
#define inf 1000000000+7
using namespace std;
typedef long long ll;
int ans[7] = { 1, 9, 18, 54, 90, 174, 258 };
int main()
{
int T;
cin >> T;
while (T--)
{
int n;
cin >> n;
cout << ans[n] << endl;
}
return 0;
}
//int main()
//{
// for (int i = 0; i <= 6; i++)
// {
// ll ans = pow(10, i);
// ll cot = 0;
// for (ll j = 1; j <= ans; j++)
// {
// stringstream ss;
// ss << j;
// string str;
// ss >> str;
// int flag = 1;
// int len;
// len = (str.size() - 1) / 2;
//
// for (int k = 0; k <= len; k++)
// {
// if (k)if (str[k] <= str[k - 1]){ flag = 0; break; }
// if (str[k] != str[str.size() - 1 - k]){ flag = 0; break; }
// }
// if (flag)cot++;
// }
// cout << cot << endl;
// }
// return 0;
//}