extraordinarily-large
Source: hackerearth
Difficulty: UNKNOWN_DIFFICULTY

You need to handle two extraordinarily large integers. The good news is that you don't need to perform any arithmetic operation on them. You just need to compare them and see whether they are equal or one is greater than the other.

Given two strings x and y, print either "x< y"(ignore space, editor issues), "x>y" or "x=y" depending on the values represented by x and y. x and y each consist of a decimal integer followed zero or more '!' characters. Each '!' represents the factorial operation. For example, "3!!" represents 3!! = 6! = 720.

Input - First line of input contains no. of testcases and each test consist of 2 lines x and y.

Ouptut - Print the required output.

SAMPLE INPUT
3
0!
1
9!!
999999999
456!!!
123!!!!!!

SAMPLE OUTPUT
x=y
x>y
x<y


import math


def fac(ans1,ans2):
	for i in range(ans1-1,0,-1):
		ans1=i*ans1
		if (ans1>ans2):
			return ans1
	return ans1
for i in range(int(input())):
    m=input()
    x=m.split('!')
    
    n=input()
    y=n.split('!')
    ans1=int(x[0])
    ans2=int(y[0])
    
    p=len(m)-len(str(ans1))
    q=len(n)-len(str(ans2))
  
    if(ans1==0):
        if(p!=0):
            p=0
            ans1=1
    if(ans2==0):
        if(q!=0):
            q=0
            ans2=1
    
    if (ans1==0 and ans2==1):
    	if (p==q and p!=0) or (q==0 and p!=0):
    		print("x=y")
    		print("adi boy")
    		continue
    if (ans1==1 and ans2==0):
    	if (p==q and p!=0) or (p==0 and q!=0):
    		print("x=y")
    		print("adi boy")
    		continue
    		
   
    if p>q :
    	p=p-q
    	q=0
    else:
    	q=q-p
    	p=0
    #print p
    #print q
    if p==q:
    	p=0
    elif q==0:
    	for k in range(p):
    		 ans1=fac(ans1,ans2)
        	 if ans1>ans2:
        	 	break
        	
       
    
    elif p==0 :
    	for k in range(q):
    		ans2=fac(ans2,ans1)
        	if ans2>ans1:
        		break
    #print ans1
    #print ans2
        	
        
        
        
    if ans1==ans2 :
    	print("x=y");
    elif ans2>ans1 :
        print("x<y");
    else :
        print("x>y");
        


t = eval(input())
while t:
	t-=1
	a = input()
	b = input()
	cnt1=0
	cnt2=0
	i=len(a)-1
	while i>=0 and a[i]=='!':
		i-=1
		cnt1+=1
	i=len(b)-1
	while i>=0 and b[i]=='!':
		i-=1
		cnt2+=1
	swapped = 0
	if cnt2<cnt1:
		cnt2,cnt1=cnt1,cnt2
		a,b=b,a
		swapped = 1
	a = a[:len(a)-cnt1]
	b = b[:len(b)-cnt2]
	b = int(b)
	a = int(a)
	if a==0:
		if cnt1>0:
			a=1
			cnt1-=1
	if b==0:
		if cnt2>0:
			cnt2-=1
			b=1
	flag1 = cnt1
	flag2 = cnt2
	cnt2 = cnt2-cnt1
	cnt1=0
	
	val = b
	
	while cnt2>0 and val<=a:
		b=val-1
		while b>0 and val<=a:
			val = val*b
			b-=1	
		cnt2-=1
	if swapped == 1:
		a,val = val,a
	if val > a:
		print("x<y")
	elif val == a:
		print("x=y")
	else:
		print("x>y")
	


t = eval(input())

while(t>0):
	q = input()
	w = input()

	len1 = len(q)
	len2 = len(w)
	p=0

	while(len1>0 and len2>0 and q[len1-1]=='!' and w[len2-1]=='!'):
		len1 = len1-1
		len2 = len2-1
		p=1

	num1=0
	num2=0

	fact1=0
	fact2=0

	i=len1-1
	while(i>=0 and q[i]=='!'):
		fact1=fact1+1
		i=i-1
		
	i = len2-1
	while(i>=0 and w[i]=='!'):
		fact2=fact2+1
		i = i-1

	num1 = int(q[:len1-fact1])
	num2 = int(w[:len2-fact2])
	
	l=0
	if(fact1!=0):
		num1,num2=num2,num1
		fact1,fact2=fact2,fact1
		l=1
	if(p==1 and num1==0):
		num1=1
	
	k = num2
	if(k==0 and fact2>0):
		k=1
	while(fact2>0):
		i = k-1
		while(i>0 and k<num1):
			k = k*i
			i=i-1
		if(k>num1):
			break
		fact2 = fact2-1

	if(l==1):
		k,num1=num1,k
	
	if(k==num1):
		print("x=y")
	elif(num1<k):
		print("x<y")
	else:
		print("x>y")
	

	t = t-1


t = eval(input())
while t:
	t-=1
	a = input()
	b = input()
	cnt1=0
	cnt2=0
	i=len(a)-1
	while i>=0 and a[i]=='!':
		i-=1
		cnt1+=1
	i=len(b)-1
	while i>=0 and b[i]=='!':
		i-=1
		cnt2+=1
	swapped = 0
	if cnt2<cnt1:
		cnt2,cnt1=cnt1,cnt2
		a,b=b,a
		swapped = 1
	a = a[:len(a)-cnt1]
	b = b[:len(b)-cnt2]
	b = int(b)
	a = int(a)
	if a==0:
		if cnt1>0:
			a=1
			cnt1-=1
	if b==0:
		if cnt2>0:
			cnt2-=1
			b=1
	flag1 = cnt1
	flag2 = cnt2
	cnt2 = cnt2-cnt1
	cnt1=0
	
	val = b
	
	while cnt2>0 and val<=a:
		b=val-1
		while b>0 and val<=a:
			val = val*b
			b-=1	
		cnt2-=1
	if swapped == 1:
		a,val = val,a
	if val > a:
		print("x<y")
	elif val == a:
		print("x=y")
	else:
		print("x>y")
	


t = eval(input())
while t:
	t-=1
	a = input()
	b = input()
	cnt1=0
	cnt2=0
	i=len(a)-1
	while i>=0 and a[i]=='!':
		i-=1
		cnt1+=1
	i=len(b)-1
	while i>=0 and b[i]=='!':
		i-=1
		cnt2+=1
	swapped = 0
	if cnt2<cnt1:
		cnt2,cnt1=cnt1,cnt2
		a,b=b,a
		swapped = 1
	a = a[:len(a)-cnt1]
	b = b[:len(b)-cnt2]
	b = int(b)
	a = int(a)
	if a==0:
		if cnt1>0:
			a=1
			cnt1-=1
	if b==0:
		if cnt2>0:
			cnt2-=1
			b=1
	flag1 = cnt1
	flag2 = cnt2
	cnt2 = cnt2-cnt1
	cnt1=0
	
	val = b
	
	while cnt2>0 and val<=a:
		b=val-1
		while b>0 and val<=a:
			val = val*b
			b-=1	
		cnt2-=1
	if swapped == 1:
		a,val = val,a
	if val > a:
		print("x<y")
	elif val == a:
		print("x=y")
	else:
		print("x>y")