from functools import reduce
BX = int( input().split()[1] )
X = [ int(x) for x in input().split() ]
X = reduce( lambda a,b: a*BX+b, X )
BY = int( input().split()[1] )
Y = [ int(x) for x in input().split() ]
Y = reduce( lambda a,b: a*BY+b, Y )
print( '=<>'[(X<Y)+2*(X>Y)] )
ZnJvbSBmdW5jdG9vbHMgaW1wb3J0IHJlZHVjZQoKQlggPSBpbnQoIGlucHV0KCkuc3BsaXQoKVsxXSApClggPSBbIGludCh4KSBmb3IgeCBpbiBpbnB1dCgpLnNwbGl0KCkgXQpYID0gcmVkdWNlKCBsYW1iZGEgYSxiOiBhKkJYK2IsIFggKQoKQlkgPSBpbnQoIGlucHV0KCkuc3BsaXQoKVsxXSApClkgPSBbIGludCh4KSBmb3IgeCBpbiBpbnB1dCgpLnNwbGl0KCkgXQpZID0gcmVkdWNlKCBsYW1iZGEgYSxiOiBhKkJZK2IsIFkgKQoKcHJpbnQoICc9PD4nWyhYPFkpKzIqKFg+WSldICk=