# WA in SWPDGT

I attempted a problem on codechef, and came up with an answer, it works with all the testcases i know, but according to codechef is a wrong answer. I read a couple correct submission answers, but they followed the same logic. I have o idea where i went wrong. Please help.

Your code does not work correctly if numbers are 18 and 49. It should give answer 139 but it gives answer 103.

Just four lines are enough to solve this problem. Have a look. It will be clear.
https://www.codechef.com/viewsolution/30814498

https://www.codechef.com/viewsolution/32753766
This is my solution tell me where it fails?

t=int(input())
for i in range(t):
a,b=map(int,input().split())
if(a>10 and b>10):
e=a//10
f=a%10
g=b//10
h=b%10
if(e<h):
a=b=0
a=((a+h)*10)+f
b=((b+g)*10)+e
elif(g<f):
a=b=0
a=((a+e)*10)+g
b=((b+f)*10)+h
print(a+b)
elif(b<10):
e=a//10
f=a%10
m=b
if(b>e):
a=b=0
a=((a+m)*10)+f
b=e
print(a+b)
elif(a<10):
g=b//10
h=b%10
k=a
if(a>g):
a=b=0
b=((b+k)*10)+h
a=g
print(a+b)
else:
print(a+b)