#include using namespace std; #define int long long template void chmin(T &a,T b){ if(a>b)a=b; } template void chmax(T &a,T b){ if(a>n; int ans=5e18; while(n--){ string s;cin>>s; int T=0; for(auto p:s){ if(p>='0'&&p<='9')chmax(T,(int)(p-'0')); else chmax(T,(int)(p-'A'+10)); } int res=0; for(auto p:s){ res*=T+1; if(p>='0'&&p<='9')res+=(int)(p-'0'); else res+=(int)(p-'A'+10); } chmin(ans,res); } cout<