#include #include #include #include #include #include using namespace std; int main(){ long long nums[100]; int opers[100]; // 1=+ 2=* bool mode = 1; // 1 no 0 op char ch; int l; ch = getchar(); while(ch != 'E'){ l = 0; mode = 1; while(ch != '\n'){ long long no = 0; while(int(ch) >= int('0') && int(ch) <= int('9')){ no *= 10; no += int(ch)-int('0'); ch = getchar(); } nums[l] = no; if(ch == '+') opers[l] = 1; if(ch == '*') opers[l] = 2; if(ch == '+' || ch == '*'){ch = getchar(); l++;} } long long aprod = nums[0]; long long products = 1; long long fproducts = 1; long long faprod = nums[0]; for(int i = 0; i < l; i++){ if(opers[i] == 1){ aprod += nums[i+1]; faprod += nums[i+1]; } else if(nums[i+1] == 0){ faprod -= nums[i]; products *= aprod; aprod = nums[i+1]; } else{ products*=aprod; aprod = nums[i+1]; fproducts*=faprod; faprod = nums[i+1]; } } products *= aprod; fproducts *= faprod; long long adding = 0; aprod = nums[0]; for(int i = 0; i < l; i++){ if(opers[i] == 1){ adding += aprod; aprod = nums[i+1]; } else{ aprod *= nums[i+1]; } } adding += aprod; printf("%lld %lld\n", min(products, adding), max(fproducts, adding)); ch = getchar(); } return 0; }