#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define rep(i,n) for(int i=0;i=0;i--) #define DREP(i,n) for(int i=n;i>0;i--) #define Rep(i,m,n) for(int i=m;i vi; typedef vector > vvi; typedef pair pdd; typedef pair pii; const double pi=acos(-1.0); double rad(double t){return t*pi/180.0;} double deg(double d){return d*180.0/pi;} int GCD(int x,int y){if(x> n; string S; rep(i,n){ char c; cin >> c; S.pb(c); } sort(all(S)); LL m=pow(10,14),M=-pow(10,14); do{ if(!check(S))continue; LL ans=evaluation(S); m=min(m,ans); M=max(M,ans); }while(next_permutation(all(S))); cout << M << ' ' << m << endl; return 0; }