Seven-Segment Display Addition

Time limit1sMemory limit128 MB

Summary
Decode two seven-segment code strings into integers, add them, then re-encode the sum using the given digit codes.
Level

Easy3 of 10

Topics
String, Implementation, Hash map, Math
Solved
No attempts yet

Problem

A seven-segment display is made up of seven LEDs. Each LED can be turned on or off independently, so — excluding the case where all of them are off — there are 127 possible on/off combinations, mostly used to show the digits 0 through 9.

The display is controlled by sending it a single 7-bit binary number that decides which LEDs light up. The decimal value of this 7-bit number is called its code. For example, if the LED combination that shows the digit 1 has the binary value 0001010, then its decimal value, 10, is the code for the digit 1. Because a code is at most 127, every code can be written as a three-digit decimal number (padded with leading zeros), so the code for the digit 1 is 010.

The codes for the digits 0 through 9 are as follows.

DigitCode
0063
1010
2093
3079
4106
5103
6119
7011
8127
9107

A number with two or more digits is written by concatenating the code of each digit, from the most significant digit to the least. For example, 13 is written as 010079 and 144 as 010106106.

Given A and B, the seven-segment codes of two numbers, write a program that outputs the sum of the two numbers, again as a seven-segment code.

Input

The input consists of several test cases. Each test case is a single line of the form A+B=, where A and B are the seven-segment codes of positive integers a and b, respectively. They satisfy 0<a, b<a+b<1090 < a,\ b < a + b < 10^{9}. The last line of the input is BYE.

Output

For each test case, print A+B=C on its own line. A and B are exactly the strings given in the input, and C is the seven-segment code of a + b.

Examples2

  1. Example 1

    Input
    010079010+010079=
    106010+010=
    BYE
    
    Expected output
    010079010+010079=010106106
    106010+010=106093
    
  2. Example 2

    Input
    010+010=
    BYE
    
    Expected output
    010+010=093