#include using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x>N; FOR(i,N) { cin>>S[i]; ll ret=0; mi='1'; FOR(j,S[i].size()) mi=max(mi,S[i][j]); if(isdigit(mi)) dig=mi-'0'+1; else dig=mi-'A'+10+1; FOR(j,S[i].size()) { ret = ret*dig + ((S[i][j]<='9')?(int)S[i][j]-'0':(S[i][j]-'A'+10)); } mimi=min(mimi,ret); } cout<