#include <iostream>
#include <cstdio>
#include <cstdio>
#include <cstring>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#define LMT 5000000
#define ll long long
using namespace std;
bool cmp(int a,int b)
{
return a>b;
}
ll _pow(int a,int p)
{
ll ans=1;
while(p--)
{
ans=ans*a;
if(ans>=LMT)
return LMT;
}
return ans;
}
int main()
{
vector<int> vb;
int t,n,k;
ll total,r;
scanf("%d",&t);
bool exceed;
while(t--)
{
vb.clear();
total=0;
while(scanf("%d",&n)&&n)
{
vb.push_back(n);
}
sort(vb.begin(),vb.end(),cmp);
exceed=0;
for(int i=0;i<vb.size();i++)
{
r =_pow(vb[i],i+1);
r*=2;
if(r>LMT)
{
exceed=1;break;
}
total+=r;
if(total>LMT)
{
exceed=1;break;
}
}
if(exceed)
printf("Too expensive\n");
else
printf("%lld\n",total);
}
return 0;
}