Problem hidden
This problem was hidden by Editorial Board member probably because it has incorrect language version or invalid test data, or description of the problem is not clear.

ADDING - Adding reversed numbers (challenge)

The Antique Comedians of Malidinesia prefer comedies to tragedies. Unfortunately, most of the ancient plays are tragedies. Therefore the dramatic advisor of ACM has decided to transfigure some tragedies into comedies. Obviously, this work is very hard because the basic sense of the play must be kept intact, although all the things change to their opposites. For example the numbers: if any number appears in the tragedy, it must be converted to its reversed form before being accepted into the comedy play.

Reversed number is a number written in arabic numerals but the order of digits is reversed. The first digit becomes last and vice versa. For example, if the main hero had 1245 strawberries in the tragedy, he has 5421 of them now. Note that all the leading zeros are omitted. That means if the number ends with a zero, the zero is lost by reversing (e.g. 1200 gives 21). Also note that the reversed number never has any trailing zeros.

ACM needs to calculate with reversed numbers. Your task is to add two reversed numbers and output their reversed sum. Of course, the result is not unique because any particular number is a reversed form of several numbers (e.g. 21 could be 12, 120 or 1200 before reversing). Thus we must assume that no zeros were lost by reversing (e.g. assume that the original number was 12).

Input

The input consists of N cases (equal to about 100). The first line of the input contains only positive integer N. Then follow the cases. Each case consists of exactly one line with two positive integers separated by space. These are the reversed numbers you are to add.

Warning: Even unsigned long long int isn't enought for this task.

Output

For each case, print exactly one line containing only one integer - the reversed sum of two reversed numbers. Omit any leading zeros in the output.

Example

Input:
3
24 1
4358 754
305 794

Output:
34
1998
1

Added by:Piotr Kąkol
Date:2010-08-07
Time limit:4.849s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: NODEJS OBJC SCM qobi VB.NET
Resource:Copy of Adrian Kosowski's task ADDREV.

hide comments
2011-01-17 11:58:59 HWK
I know this message. It's desired. ;-) But the problem isn't the Zerodivision because this output goes to stderr not to stdout. In other tasks this was accepted.
Redirect the output in a file, look at it with a hexeditor and "cat" it to the screen. Then you should understand.

Last edit: 2011-01-17 12:05:43
2011-01-17 11:03:06 Piotr KÄ…kol
But Your error for 4590458 and 4590461 is:
dc: divide by zero
There's nothing like "screen control codes" (but I don't know Bash, so tell me if "dividing by zero" is caused by this "screen control codes").

Last edit: 2011-01-17 11:03:56
2011-01-16 16:56:23 HWK
It seems that the judge doesn't understand "screen control codes". So my solution (shorter than 49 bytes) which gives the right results on my screen wasn't accepted. Would you think about changing the judge to allow such tricks?
2011-01-07 11:42:14 Hallvard Norheim Bø
Thanks, I forgot that Python treat numbers with leading zeroes as octal.
2011-01-07 01:00:17 Piotr KÄ…kol
That's the error:
Traceback (most recent call last):
File "/sources/tested.py", line 1, in
File "", line 1, in
File "", line 1
069785625623733309786098674083338386888298821462249641347153492050639944526919040838209255022+40169240840785701941995123167206992827896576264004665083396919304301131809926042748
^
SyntaxError: invalid token

// There are to trailing spaces.

Last edit: 2011-01-07 01:03:37
2011-01-07 00:38:00 Hallvard Norheim Bø
Why does my submission #4546058 give RE? It works when I run it locally.

I suspect that it may be caused by trailing spaces.

Last edit: 2011-01-07 00:40:02
2010-12-11 17:00:40 Kousthub Raja
Don't try to store the number in an integer and do the maths. Use a string and then add each decimal place with carries.
2010-11-09 14:34:16 Piotr KÄ…kol
My pleasure.
Congratulations. :-)
2010-11-09 10:11:59 Piotr Fusik
Thank you. :)
2010-11-08 20:36:41 Piotr KÄ…kol
Sorry for the delay:
1
675356291270936062618792023759228973612931947845036106320615547656937452547443078688 3149206892664950487172722610615949091771159776736563948129390885096385611598481030444
Correct answer:
9892868715373321014350752847118139828890568255296825902425546262656750246963912717235
Yours:
98928687153733210
+ error: "(standard_in) 1: illegal character: \"
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.