extraordinarily-large-1
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


def main():
	t=int(input())
	while t!=0:
		t-=1
		x=input()
		y=input()
		xcount,ycount=0,0
		i=len(x)-1
		while x[i]=='!':
			xcount+=1
			i-=1
		i=len(y)-1
		while y[i]=='!':
			ycount+=1
			i-=1
		new_x=x[:len(x)-xcount]
		new_y=y[:len(y)-ycount]
		new_x=int(new_x)
		new_y=int(new_y)
		if new_x==0 and xcount>0:
			new_x=1
		if new_y==0 and ycount>0:
			new_y=1
		sflag=False
		if xcount>ycount:
			new_x,new_y=new_y,new_x
			xcount,ycount=ycount,xcount
			sflag=True
		ycount=ycount-xcount
		dflag=False
		while ycount>0:
			ycount=ycount-1
			val=new_y-1
			while val>0:
				new_y=new_y*val
				val-=1
				if new_y>new_x:
					dflag=True
					break
			if dflag:
				break
		if sflag:
			new_x,new_y=new_y,new_x
		if new_x>new_y:
			print("x>y")
		elif new_x==new_y:
			print("x=y")
		else:
			print("x<y")
	
if __name__=='__main__':
	main()


cases = int(input())

def antifact(num):
	j = 1
	while num>=j:
		num /= j
		j += 1
	
	return j

def fact(num, comp):
	ans = 1
	for i in range(num):
		ans*=(i+1)
		if ans > comp:
			return -1
	return ans
	
for case in range(cases):
	x = input()
	y = input()
	
	
	if x.find('!')!=-1:
		xn, xf = int(x[:x.find('!')]), len(x[x.find('!'):])
	else:
		xn, xf = int(x), 0
	if y.find('!')!=-1:
		yn, yf = int(y[:y.find('!')]), len(y[y.find('!'):])
	else:
		yn, yf = int(y), 0
	
	
	if (xn, yn, xf, yf) in [(0, 1, 1, 0),(1, 0, 0, 1),(1, 0, 1, 1),(0, 1, 1, 1)]:
		xn = yn
		xf = yf
	
		
	while xf!=yf:
		if xf>yf:
			if(xn>yn):
				break
			xn = fact(xn, yn)
			if xn==-1:
				xn = yn+1
				break
			xf -= 1
		else:
			if(yn>xn):
				break
			yn = fact(yn, xn)
			if yn==-1:
				yn = xn+1
				break
			yf -= 1
		
	if xn==yn:
		print("x=y")
	
	elif xn>yn:
		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:
	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")


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