12395 - Storm Area 51   

Description

An fandom anime opening of Area51 Raid event.

If we naruto run, we can move faster than their bullets.

── Unknown naruto runner

"Storm Area 51, They Can't Stop All of Us" is an event that invites everyone to intrude into the famous America military base "Area 51" on Sep. 20, 2019. In this event, participants are asked to use naruto run to intrude Area 51 so that they can move faster than their bullets.

However, performing naruto run challenges the control of Chakra(查克拉) of the runner. They have to control the flow of Chakra and distribute it appropriately so that they could be able to run steadily.

A runner run over the camera. Shot in 1/1000 sec. The original report is here.


On every step, a pre-order binary expression and some values would cross runners' mind. Runners needs to rearrange the binary expression into in-order and calculate the answer of this expression, so that they can naruto run steadily and dodge those bullets.

You are an adviser of this event. Somehow you can read the runners' mind and tell them the answers of these expressions. You're going to write a program to help them, otherwise they will be hit by bullets.

Because naruto run is a simple ninjutsu(忍術), the expression won't be too complicated, so the variables in an expression won't exceed 3(). And we don't care about the parentheses.


Take the sample as example:

We use the pre-order binary expression the build a syntax tree, the tree should look like the following graph:

G / / + + /->+ 4 4 /->4 x x +->x * * +->* 3 3 *->3 y y *->y

Now, we can write down the in-order: x+3*y/4. Note that we don't add spaces or parentheses.

And we know that , then calculate the answer: .

Note that we only pick the integer part to calculate.

Input

The first line contains the whole expression in pre-order. The length of the input string wouldn't exceed 100.

The input expression would contain:

  • variable
  • operator
  • integers in range

The second line contains three integers represent , , , respectively.

. You don't have to worry about overflow or underflow.

Note that there will be a space after every operator, number, and variable. Please refer to the sample.

Output

On the first line, output the expression in in-order. There should be no space between every operator, number, and variable.

On the second line, output the result of this expression.

Sample Input  Download

Sample Output  Download

Tags




Discuss