Timer is Running

Swap the closest and farthest digits
##### Submissions: 1417   Accuracy: 39.2%   Difficulty: Easy   Marks: 2

Given two numbers N1 and N2 that are separated by a space, we need to swap first digit of first number with last digit of second number and last digit of first number with the first digit of second number.

Input:

The first line of the input contains a single integer T, denoting the number of test cases. Then T test cases follow. Each test case has a single line input where two integers N1 and N2, which are separated by a space, are inputted.

Output:
Print two numbers separated by a space such that first digit of first number has been swapped with last digit of second number and last digit of first number has been swapped with the first digit of second number.

Constraints:

1<=T<=100
10<=N1<=1020
10<=N2<=1020

Example:

Input:

4
1234 5678
8903 4863
12 21
666 999

Output:

8235 4671
3904 3868
12 21
969 696

Explanation:

Test case 1: 1234 5678

[1]23(4)    (5)67[8]
|       |_
SWAP_|     |
|_____
SWAP____|

Hence we get 8235 4671 as the answer

#### ** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Ankit Sharma
Author: Soul_xhacker

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.