Playing with Matches
All submissions for this problem are available.### Read problems statements in [Mandarin Chinese](http://www.codechef.com/download/translated/COOK110/mandarin/MATCHES.pdf), [Russian](http://www.codechef.com/download/translated/COOK110/russian/MATCHES.pdf), [Vietnamese](http://www.codechef.com/download/translated/COOK110/vietnamese/MATCHES.pdf), and [Bengali](http://www.codechef.com/download/translated/COOK110/bengali/MATCHES.pdf) as well. Chef's son Chefu found some matches in the kitchen and he immediately starting playing with them. The first thing Chefu wanted to do was to calculate the result of his homework — the sum of $A$ and $B$, and write it using matches. Help Chefu and tell him the number of matches needed to write the result. Digits are formed using matches in the following way: !(https://codechef_shared.s3.amazonaws.com/download/Images/COOK110/MATCHES...) ### Input - The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. - The first and only line of each test case contains two space-separated integers $A$ and $B$. ### Output For each test case, print a single line containing one integer — the number of matches needed to write the result ($A+B$). ### Constraints - $1 \le T \le 1,000$ - $1 \le A, B \le 10^6$ ### Example Input ``` 3 123 234 10101 1010 4 4 ``` ### Example Output ``` 13 10 7 ``` ### Explanation **Example case 1:** The result is $357$. We need $5$ matches to write the digit $3$, $5$ matches to write the digit $5$ and $3$ matches to write the digit $7$. **Example case 2:** The result is $11111$. We need $2$ matches to write each digit $1$, which is $2 \cdot 5 = 10$ matches in total.
|Tags||cakewalk, cook110, kingofnumbers, taran_1407|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.