Big Math

The people at Awesome Color Monitors (ACM), Inc., makers of the Ginormatron – those big scoreboard monitors used at most sports stadiums, are looking for new uses for their products. One of the areas they are most interested in supporting is education in children. To this end, they would like to use their scoreboards to teach simple mathematics to large groups of youngsters. Once the stadium is filled with children, the scoreboard will display a simple mathematical equation, and then, after a brief pause, print the answer underneath. Your job is to read in such equations, perform the calculations, and print the result in “scoreboard” format. The standard precedence and associatively of mathematical operators apply, so ‘∗’ and ‘/’ have precedence over ‘+’ and ‘-’, and equations are performed left to right. Each number or operator is displayed in a 3 × 5 array of pixels. Each number or operator is separated by one space. You can assume that: • all equations are well formed • there are no divide-by-zero errors • all numbers are positive integers • operators appear as binary operators only • division means integer division • the intermediate and final results will fit in a 32-bit signed integer. The numbers and operators appear in the input as follows (without the labels underneath): 000 .0. 000 000 0.0 000 0.. 000 000 000 .0. ... 0.0 .0. 0.0 .0. ..0 ..0 0.0 0.. 0.. ..0 0.0 0.0 .0. ... 0.0 ... 0.0 .0. 000 000 000 000 000 ..0 000 000 000 000 .0. 000 0.0 .0. 0.. ..0 ..0 ..0 0.0 ..0 0.0 ..0 .0. ... 0.0 ... 000 .0. 000 000 ..0 000 000 ..0 000 ..0 .0. ... 0.0 .0. 0123456789+~*/ As an example, the equation “128 + 256” in scoreboard notation would be: .0. 000 000 .0. 000 000 0.. .0. ..0 0.0 .0. ..0 0.. 0.. .0. 000 000 000 000 000 000 .0. 0.. 0.0 .0. 0.. ..0 0.0 .0. 000 000 .0. 000 000 000 The resulting answer, 384, in scoreboard form would be: 000 000 0.0 ..0 0.0 0.0 000 000 000 ..0 0.0 ..0 000 000 ..0

2/2 Input The input consists of a sequence of equations in scoreboard notation. Each equation is contained on one scoreboard-notation line, followed by a blank line. The maximum number of scoreboard notation characters in one equation is 20. The end of input is denoted by a zero in scoreboard notation on a line by itself. Output For each equation, compute the resulting answer, and print your output in scoreboard notation, followed by a blank line. Sample Input .0. 000 .0. 0.0 .0. 000 .0. .0. 0.0 .0. 0.0 .0. 0.0 .0. .0. 0.0 .0. .0. .0. 0.0 .0. .0. 0.0 .0. 0.0 .0. 0.0 .0. .0. 000 .0. 0.0 .0. 000 .0. 000 000 0.0 0.0 .0. 0.0 000 ..0 ..0 0.0 0.0 .0. 0.0 ..0 000 000 .0. 000 .0. .0. 000 0.. ..0 0.0 ..0 .0. 0.0 ..0 000 000 0.0 ..0 .0. 0.0 000 000 0.0 0.0 0.0 000 Sample Output .0. 000 000 000 .0. .0. 0.0 ..0 0.0 .0. .0. 0.0 000 0.0 .0. .0. 0.0 0.. 0.0 .0. .0. 000 000 000 .0. 000 000 000 000 ..0 0.0 ..0 0.0 000 000 000 000 0.. 0.0 0.. ..0 000 000 000 ..0