Add Backward Numbers
InterviewTime limit1sMemory limit128 MB
Add two numbers whose digits are given in reverse order, printing the sum with its digits also reversed and no leading zeroes.
- Level
Easy3 of 10
- Topics
- Math, String, Implementation, Simulation
- Solved
- No attempts yet
Problem
A backward number is written in ordinary Arabic numerals, but with the order of its digits reversed: the first digit becomes the last, and vice versa. For example, the number becomes .
All leading zeroes are omitted. So if a number ends in a zero, that zero is lost by the reversal; for example, becomes . Consequently, a backward number never has any trailing zeroes.
Your task is to add two backward numbers and output their sum, again as a backward number. In general the result is not unique (for example, could have come from , , or ), so we assume that no zeroes were lost in the reversal (that is, we assume the original number was ).
Input
The first line contains a single integer (), the number of cases. Each of the following lines contains two non-negative integers separated by a space; these are the backward numbers to add. Every number satisfies .
Output
For each case, print exactly one line containing a single integer: the backward sum of the two backward numbers. Omit any leading zeroes.