After seeing the "ALL YOUR BASE ARE BELONG TO US" meme for the first time, numbers X and Y realised that they have different bases, which complicated their relations.

You're given a number X represented in base b_{x} and a number Y represented in base b_{y}. Compare those two numbers.


-----Input-----

The first line of the input contains two space-separated integers n and b_{x} (1 ≤ n ≤ 10, 2 ≤ b_{x} ≤ 40), where n is the number of digits in the b_{x}-based representation of X. 

The second line contains n space-separated integers x_1, x_2, ..., x_{n} (0 ≤ x_{i} < b_{x}) — the digits of X. They are given in the order from the most significant digit to the least significant one.

The following two lines describe Y in the same way: the third line contains two space-separated integers m and b_{y} (1 ≤ m ≤ 10, 2 ≤ b_{y} ≤ 40, b_{x} ≠ b_{y}), where m is the number of digits in the b_{y}-based representation of Y, and the fourth line contains m space-separated integers y_1, y_2, ..., y_{m} (0 ≤ y_{i} < b_{y}) — the digits of Y.

There will be no leading zeroes. Both X and Y will be positive. All digits of both numbers are given in the standard decimal numeral system.


-----Output-----

Output a single character (quotes for clarity):   '<' if X < Y  '>' if X > Y  '=' if X = Y 


-----Examples-----
Input
6 2
1 0 1 1 1 1
2 10
4 7

Output
=

Input
3 3
1 0 2
2 5
2 4

Output
<

Input
7 16
15 15 4 0 0 7 10
7 9
4 8 0 3 1 5 0

Output
>



-----Note-----

In the first sample, X = 101111_2 = 47_10 = Y.

In the second sample, X = 102_3 = 21_5 and Y = 24_5 = 112_3, thus X < Y.

In the third sample, $X = FF 4007 A_{16}$ and Y = 4803150_9. We may notice that X starts with much larger digits and b_{x} is much larger than b_{y}, so X is clearly larger than Y.

Source: codeforces | Difficulty: EASY
Tags: Implementation

Complete search


Solutions:
(n, x) = map(int, input().split())
arrx = list(map(int, input().split()))
(m, y) = map(int, input().split())
arry = list(map(int, input().split()))
sumx = sumy = 0
for i in range(n):
	sumx += pow(x, n - 1 - i) * arrx[i]
for j in range(m):
	sumy += pow(y, m - 1 - j) * arry[j]
if sumx > sumy:
	print('>')
elif sumx < sumy:
	print('<')
else:
	print('=')


import unittest
import sys

class Mem:

	def __init__(self, test_inputs=None):
		it = iter(test_inputs.split('\n')) if test_inputs else None

		def uinput():
			return next(it) if it else sys.stdin.readline().rstrip()
		[self.n, self.bx] = map(int, uinput().split())
		self.numsx = list(map(int, uinput().split()))
		[self.m, self.by] = map(int, uinput().split())
		self.numsy = list(map(int, uinput().split()))
		self.x = 0
		for n in self.numsx:
			self.x = self.x * self.bx + n
		self.y = 0
		for n in self.numsy:
			self.y = self.y * self.by + n

	def calculate(self):
		if self.x == self.y:
			return '='
		if self.x > self.y:
			return '>'
		return '<'

class unitTests(unittest.TestCase):

	def test_single_test(self):
		test = '6 2\n1 0 1 1 1 1\n2 10\n4 7'
		d = Mem(test)
		self.assertEqual(d.n, 6)
		self.assertEqual(d.m, 2)
		self.assertEqual(Mem(test).calculate(), '=')
		test = '3 3\n1 0 2\n2 5\n2 4'
		self.assertEqual(Mem(test).calculate(), '<')
		test = '7 16\n15 15 4 0 0 7 10\n7 9\n4 8 0 3 1 5 0'
		self.assertEqual(Mem(test).calculate(), '>')
		test = ''

	def time_limit_test(self, nmax):
		import random
		import timeit
		test = str(nmax) + ' ' + str(nmax) + '\n'
		numnums = [str(i) + ' ' + str(i + 1) for i in range(nmax)]
		test += '\n'.join(numnums) + '\n'
		nums = [random.randint(1, 10000) for i in range(nmax)]
		test += ' '.join(map(str, nums)) + '\n'
		start = timeit.default_timer()
		d = Mem(test)
		calc = timeit.default_timer()
		d.calculate()
		stop = timeit.default_timer()
		print('\nTimelimit Test: ' + '{0:.3f}s (init {1:.3f}s calc {2:.3f}s)'.format(stop - start, calc - start, stop - calc))
sys.setrecursionlimit(100000)
if sys.argv[-1] == '-ut':
	unittest.main(argv=[' '])
sys.stdout.write(Mem().calculate())


import sys
import math
import bisect

def main():
	(n, b1) = map(int, input().split())
	x = 0
	for a in list(map(int, input().split())):
		x = x * b1 + a
	(n, b2) = map(int, input().split())
	y = 0
	for a in list(map(int, input().split())):
		y = y * b2 + a
	if x == y:
		print('=')
	elif x > y:
		print('>')
	elif x < y:
		print('<')
main()


def perevod(chislo, osnovanie, dlina):
	rez = 0
	for i in range(dlina):
		rez += chislo[i] * osnovanie ** i
	return rez
(n, bx) = map(int, input().split())
x = list(map(int, input().split()))
(m, by) = map(int, input().split())
y = list(map(int, input().split()))
x = x[::-1]
y = y[::-1]
rez1 = 0
rez2 = 0
rez1 = perevod(x, bx, n)
rez2 = perevod(y, by, m)
if rez1 == rez2:
	print('=')
elif rez1 < rez2:
	print('<')
else:
	print('>')


(n, b) = map(int, input().split())
num1 = 0
num2 = 0
n -= 1
for c in list(map(int, input().split())):
	num1 += b ** n * c
	n -= 1
(n, a) = map(int, input().split())
n -= 1
for c in list(map(int, input().split())):
	num2 += a ** n * c
	n -= 1
if num1 > num2:
	print('>')
elif num1 == num2:
	print('=')
else:
	print('<')


from math import *
from collections import deque
from copy import deepcopy
import sys

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def multi():
	return map(int, input().split())

def strmulti():
	return map(str, inp().split())

def lis():
	return list(map(int, inp().split()))

def lcm(a, b):
	return a * b // gcd(a, b)

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def stringlis():
	return list(map(str, inp().split()))

def out(var):
	sys.stdout.write(str(var))

def printlist(a):
	print(' '.join((str(a[i]) for i in range(len(a)))))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
(n, ba) = multi()
a = lis()
astr = ''
(nb, bb) = multi()
b = lis()
num = 0
num1 = 0
for i in range(1, n + 1):
	num += a[-i] * ba ** (i - 1)
for i in range(1, nb + 1):
	num1 += b[-i] * bb ** (i - 1)
bstr = ''
if num == num1:
	print('=')
elif num > num1:
	print('>')
else:
	print('<')


(n1, m1) = map(int, input().split())
a1 = list(map(int, input().split()))
ans1 = 0
ind1 = n1 - 1
for i in a1:
	ans1 += i * m1 ** ind1
	ind1 -= 1
(n2, m2) = map(int, input().split())
a2 = list(map(int, input().split()))
ans2 = 0
ind2 = n2 - 1
for i in a2:
	ans2 += i * m2 ** ind2
	ind2 -= 1
if ans1 == ans2:
	print('=')
elif ans1 > ans2:
	print('>')
else:
	print('<')


import operator
II = lambda : map(int, input().split())
(dx, bx) = II()
X = sum(map(operator.mul, map(operator.pow, [bx] * dx, range(dx - 1, -1, -1)), II()))
(dy, by) = II()
Y = sum(map(operator.mul, map(operator.pow, [by] * dy, range(dy - 1, -1, -1)), II()))
print('=' if X == Y else '<' if X < Y else '>')


def fun(m, b, L):
	ret = 0
	L.reverse()
	for i in range(m):
		ret += L[i] * b ** i
	return ret
(n, bx) = map(int, input().split())
X = list(map(int, input().split()))
xx = fun(n, bx, X)
(m, by) = map(int, input().split())
Y = list(map(int, input().split()))
yy = fun(m, by, Y)
if xx > yy:
	print('>')
elif xx < yy:
	print('<')
else:
	print('=')


(a, A) = map(int, input().split())
t = list(map(int, input().split()))[::-1]
(b, B) = map(int, input().split())
y = list(map(int, input().split()))[::-1]
h = 0
for j in range(a):
	h += t[j] * A ** j
g = 0
for i in range(b):
	g += y[i] * B ** i
if h > g:
	print('>')
elif g > h:
	print('<')
else:
	print('=')


s1 = input().split()
n = int(s1[0])
m = int(s1[1])
s = list(map(int, input().split()))
s2 = input().split()
z = int(s2[0])
x = int(s2[1])
d = list(map(int, input().split()))
k = 0
j = 0
s.reverse()
d.reverse()
kk = 0
jj = 0
for i in range(n):
	k += m ** kk * s[i]
	kk += 1
for i in range(z):
	j += x ** jj * d[i]
	jj += 1
if k > j:
	print('>')
elif k < j:
	print('<')
else:
	print('=')


(n1, b1) = map(int, input().split())
a1 = list(map(int, input().split()))
a1.reverse()
(n2, b2) = map(int, input().split())
a2 = list(map(int, input().split()))
a2.reverse()
x = 0
y = 0
import math
for i in range(n1):
	x += a1[i] * math.pow(b1, i)
for i in range(n2):
	y += a2[i] * math.pow(b2, i)
if x == y:
	print('=')
elif x < y:
	print('<')
elif x > y:
	print('>')


from math import *
from functools import *
(N, a) = map(int, input().split())
A = reduce(lambda res, x: res * a + x, list(map(int, input().split())), 0)
(N, b) = map(int, input().split())
B = reduce(lambda res, x: res * b + x, list(map(int, input().split())), 0)
print([['>', '='][A == B], '<'][A < B])


def main():
	(n1, b1) = map(int, input().split())
	x = [int(i) for i in input().split()][::-1]
	(n2, b2) = map(int, input().split())
	y = [int(i) for i in input().split()][::-1]
	(xan, yan) = (0, 0)
	for (i, ii) in enumerate(x):
		xan += ii * b1 ** i
	for (i, ii) in enumerate(y):
		yan += ii * b2 ** i
	if xan > yan:
		print('>')
	else:
		print('=' if yan == xan else '<')
main()


inp = input().split()
n = int(inp[0])
bx = int(inp[1])
X = input().split()
for i in range(n):
	X[i] = int(X[i])
X = X[::-1]
inp = input().split()
m = int(inp[0])
by = int(inp[1])
Y = input().split()
for i in range(m):
	Y[i] = int(Y[i])
Y = Y[::-1]
sum_X = 0
base = 1
for n in X:
	sum_X += base * n
	base *= bx
sum_Y = 0
base = 1
for n in Y:
	sum_Y += base * n
	base *= by
if sum_X == sum_Y:
	print('=')
elif sum_X < sum_Y:
	print('<')
else:
	print('>')


bx = int(input().split()[1])
X = tuple(map(int, input().split()))
by = int(input().split()[1])
Y = tuple(map(int, input().split()))
x = y = 0
for d in X:
	x = x * bx + d
for d in Y:
	y = y * by + d
if x == y:
	print('=')
elif x > y:
	print('>')
else:
	print('<')


def convert():
	(n, b) = map(int, input().split())
	v = 0
	for x in map(int, input().split()):
		v = b * v + x
	return v
(x, y) = (convert(), convert())
if x > y:
	print('>')
elif x < y:
	print('<')
else:
	print('=')


vstup = input()
seznam = [int(n) for n in vstup.split()]
cislo = [int(n) for n in input().split()]
zaklad = seznam[1]
vstup2 = input()
seznam2 = [int(n) for n in vstup2.split()]
cislo2 = [int(n) for n in input().split()]
zaklad2 = seznam2[1]

def preved(cislo, zaklad):
	prvni = 0
	for k in range(len(cislo)):
		rad = len(cislo) - k - 1
		prvni2 = zaklad ** rad * cislo[k]
		prvni += prvni2
	return prvni
x = preved(cislo, zaklad)
y = preved(cislo2, zaklad2)
if x > y:
	print('>')
elif x < y:
	print('<')
else:
	print('=')


(n, bx) = map(int, input().split())
X = list(map(int, input().split()))
(m, by) = map(int, input().split())
Y = list(map(int, input().split()))

def calcul(n, bx, X):
	r = X[n - 1]
	c = 1
	for k in range(2, n + 1):
		c *= bx
		r += X[n - k] * c
	return r
x = calcul(n, bx, X)
y = calcul(m, by, Y)
if x == y:
	print('=')
elif x > y:
	print('>')
else:
	print('<')


def intlist():
	return [int(i) for i in input().split()]
(n, bx) = intlist()
x = intlist()
x.reverse()
X = 0
p = 1
for a in x:
	X += p * a
	p *= bx
(m, by) = intlist()
y = intlist()
y.reverse()
Y = 0
p = 1
for a in y:
	Y += p * a
	p *= by
if X == Y:
	print('=')
else:
	print(['<', '>'][X > Y])


def convertTo10(d, base, n):
	index = d - 1
	result = 0
	while index >= 0:
		pow = d - index - 1
		result += n[index] * base ** pow
		index -= 1
	return result
(d1, b1) = input().split()
(d1, b1) = (int(d1), int(b1))
n1 = input().split()
n1 = [int(x) for x in n1]
n110 = convertTo10(d1, b1, n1)
(d2, b2) = input().split()
(d2, b2) = (int(d2), int(b2))
n2 = input().split()
n2 = [int(x) for x in n2]
n210 = convertTo10(d2, b2, n2)
if n110 < n210:
	print('<')
elif n110 > n210:
	print('>')
else:
	print('=')


numbers = input().split()
(m, a) = (int(numbers[0]), int(numbers[1]))
bx = list(map(int, input().split()))[::-1]
numbers = input().split()
(n, b) = (int(numbers[0]), int(numbers[1]))
by = list(map(int, input().split()))[::-1]
p = 0
for x in range(m):
	p += bx[x] * a ** x
q = 0
for x in range(n):
	q += by[x] * b ** x
if p > q:
	print('>')
elif p < q:
	print('<')
else:
	print('=')


(n1, b1) = (int(x) for x in input().split())
d1 = list((int(x) for x in input().split()))
d1.reverse()
(n2, b2) = (int(x) for x in input().split())
d2 = list((int(x) for x in input().split()))
d2.reverse()
answer1 = 0
power1 = 1
for digit in d1:
	answer1 += digit * power1
	power1 *= b1
answer2 = 0
power2 = 1
for digit in d2:
	answer2 += digit * power2
	power2 *= b2
if answer1 < answer2:
	print('<')
elif answer2 < answer1:
	print('>')
else:
	print('=')


3

def make_num(lst, bx):
	res = 0
	for elem in lst:
		res *= bx
		res += elem
	return res
(n, bx) = map(int, input().split())
num1 = make_num(map(int, input().split()), bx)
(m, by) = map(int, input().split())
num2 = make_num(map(int, input().split()), by)
if num1 < num2:
	print('<')
elif num1 == num2:
	print('=')
else:
	print('>')


def get_value():
	(num_digits, base) = map(int, input().split())
	value = 0
	for digit in map(int, input().split()):
		value = base * value + digit
	return value
(x, y) = (get_value(), get_value())
if x < y:
	print('<')
elif x > y:
	print('>')
else:
	print('=')


def trans(nums, n, b):
	res = 0
	for i in range(n):
		res = res * b + nums[i]
	return res
(n, bx) = [int(x) for x in input().split()]
numXArray = [int(x) for x in input().split()]
numX = trans(numXArray, n, bx)
(m, by) = [int(x) for x in input().split()]
numYArray = [int(x) for x in input().split()]
numY = trans(numYArray, m, by)
if numX < numY:
	print('<')
elif numX > numY:
	print('>')
else:
	print('=')


(n, bx) = list(map(int, input().split()))
x = list(map(int, input().split()))
(m, by) = list(map(int, input().split()))
y = list(map(int, input().split()))
x = x[::-1]
y = y[::-1]
st = 1
ansx = 0
for i in range(n):
	ansx += x[i] * st
	st *= bx
st = 1
ansy = 0
for i in range(m):
	ansy += y[i] * st
	st *= by
print('=' if ansx == ansy else '<' if ansx < ansy else '>')


(n1, b1) = map(int, input().split())
ans1 = 0
a1 = list(map(int, input().split()))
(n2, b2) = map(int, input().split())
ans2 = 0
a2 = list(map(int, input().split()))
for i in range(n1):
	ans1 += a1[i] * b1 ** (n1 - i - 1)
for i in range(n2):
	ans2 += a2[i] * b2 ** (n2 - i - 1)
if ans1 == ans2:
	print('=')
elif ans1 > ans2:
	print('>')
else:
	print('<')


def func():
	(n, b) = map(int, input().split())
	v = 0
	for i in map(int, input().split()):
		v = b * v + i
	return v
(x, y) = (func(), func())
print('<' if x < y else '>' if x > y else '=')


def input_to_10():
	(n, base) = map(int, input().split())
	x = list(map(int, input().split()))[::-1]
	res = 0
	power = 1
	for el in x:
		res += el * power
		power *= base
	return res
a = input_to_10()
b = input_to_10()
if a == b:
	print('=')
elif a < b:
	print('<')
else:
	print('>')


r = lambda : list(map(int, input().split()))
(n, b) = r()
x = sum((x * b ** (n - 1 - i) for (i, x) in enumerate(r())))
(n, b) = r()
y = sum((x * b ** (n - 1 - i) for (i, x) in enumerate(r())))
if x == y:
	print('=')
elif x < y:
	print('<')
else:
	print('>')


(n, bx) = map(int, input().split())
x = list(map(int, input().split()))
(n, by) = map(int, input().split())
y = list(map(int, input().split()))

def to_dec(a, base):
	res = 0
	a = a[::-1]
	for (i, aa) in enumerate(a):
		res += aa * base ** i
	return res
x = to_dec(x, bx)
y = to_dec(y, by)
print('=' if x == y else '<' if x < y else '>')


x = 0
y = 0
(n, bx) = map(int, input().split())
xs = list(map(int, input().split()))
for i in range(n):
	x += xs[i] * bx ** (n - i - 1)
(m, by) = map(int, input().split())
ys = list(map(int, input().split()))
for i in range(m):
	y += ys[i] * by ** (m - i - 1)
if x == y:
	print('=')
elif x < y:
	print('<')
else:
	print('>')


(n_x, b_x) = str(input()).split()
n_x = int(n_x)
b_x = int(b_x)
line_x = str(input()).split()
sum_x = 0
for i in range(n_x):
	sum_x += pow(b_x, i) * int(line_x[n_x - 1 - i])
(n_y, b_y) = str(input()).split()
n_y = int(n_y)
b_y = int(b_y)
line_y = str(input()).split()
sum_y = 0
for i in range(n_y):
	sum_y += pow(b_y, i) * int(line_y[n_y - 1 - i])
if sum_x == sum_y:
	print('=')
elif sum_x > sum_y:
	print('>')
elif sum_x < sum_y:
	print('<')


import math
(xLen, xBase) = map(int, input().split())
xStr = input()
xArr = xStr.split()
(yLen, yBase) = map(int, input().split())
yStr = input()
yArr = yStr.split()

def toDec(base, s):
	res = 0
	for i in range(len(s)):
		res = res + int(s[len(s) - i - 1]) * math.pow(base, i)
	return round(res)
x = toDec(xBase, xArr)
y = toDec(yBase, yArr)
if x > y:
	res = '>'
elif x < y:
	res = '<'
else:
	res = '='
print(res)


def STR():
	return list(input())

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def MAP2():
	return map(float, input().split())

def LIST():
	return list(map(int, input().split()))

def STRING():
	return input()
import string
import sys
from heapq import heappop, heappush
from bisect import *
from collections import deque, Counter, defaultdict
from math import *
from itertools import permutations, accumulate
dx = [-1, 1, 0, 0]
dy = [0, 0, 1, -1]
(n, a) = MAP()
l1 = LIST()
r1 = 0
for i in l1:
	r1 += i * a ** (n - 1)
	n -= 1
(m, b) = MAP()
l2 = LIST()
r2 = 0
for i in l2:
	r2 += i * b ** (m - 1)
	m -= 1
if r1 > r2:
	print('>')
elif r1 < r2:
	print('<')
else:
	print('=')


(n, bx) = map(int, input().split())
b = list(map(int, input().split()))
ansx = 0
for i in range(n - 1, -1, -1):
	ansx += b[i] * bx ** (n - i - 1)
(m, by) = map(int, input().split())
b = list(map(int, input().split()))
ansy = 0
for i in range(m - 1, -1, -1):
	ansy += b[i] * by ** (m - i - 1)
if ansx == ansy:
	print('=')
elif ansx > ansy:
	print('>')
else:
	print('<')


from itertools import *
from collections import Counter
from operator import *
from functools import reduce
import re, math
from pprint import pprint
from fractions import gcd

def sqr(x):
	return x * x

def inputarray(func=int):
	return map(func, input().split())
(x, bx) = inputarray()
A = reversed(list(inputarray()))
(X, k) = (0, 1)
for (i, v) in enumerate(A):
	X = X + v * k
	k = k * bx
(y, by) = inputarray()
B = reversed(list(inputarray()))
(Y, k) = (0, 1)
for (i, v) in enumerate(B):
	Y = Y + v * k
	k = k * by
if X < Y:
	print('<')
elif X > Y:
	print('>')
else:
	print('=')


bx = int(input().split()[1])
x = list(map(int, input().split()))
by = int(input().split()[1])
y = list(map(int, input().split()))
X = Y = 0
for xi in x:
	X = X * bx + xi
for yi in y:
	Y = Y * by + yi
if X > Y:
	print('>')
elif X < Y:
	print('<')
else:
	print('=')


import itertools as it
import functools
import operator
import collections
import math
import sys

def solve(xs, ys, bx, by):
	x = functools.reduce(lambda acc, x: acc * bx + x, xs)
	y = functools.reduce(lambda acc, y: acc * by + y, ys)
	if x < y:
		return '<'
	elif x > y:
		return '>'
	else:
		return '='

def main():
	[n, bx] = map(int, input().strip().split())
	xs = [int(c) for c in input().strip().split()]
	assert len(xs) == n
	[m, by] = map(int, input().strip().split())
	ys = [int(c) for c in input().strip().split()]
	assert len(ys) == m
	result = solve(xs, ys, bx, by)
	print(result)
main()


(n, bx) = tuple(map(int, input().split()))
x = tuple(map(int, input().split()))
(m, by) = tuple(map(int, input().split()))
y = tuple(map(int, input().split()))
X = 0
for i in range(n):
	X += x[n - 1 - i] * bx ** i
Y = 0
for j in range(m):
	Y += y[m - 1 - j] * by ** j
if X == Y:
	print('=')
if X > Y:
	print('>')
if X < Y:
	print('<')


print((lambda x: '>' if x > 0 else '=' if x == 0 else '<')(sum((lambda n: map(lambda x: n[1] ** x[0] * x[1], list(enumerate(reversed(list(map(int, input().split())))))))(list(map(int, input().split())))) - sum((lambda bx: map(lambda x: bx[1] ** x[0] * x[1], list(enumerate(reversed(list(map(int, input().split())))))))(list(map(int, input().split()))))))


def getIn10bySt(n, st):
	m = 0
	ans = 0
	i = len(n) - 1
	while i >= 0:
		ans += int(n[i]) * st ** m
		m += 1
		i -= 1
	return ans
(n, x) = list(map(int, input().split()))
a = list(map(int, input().split()))
X = getIn10bySt(a, x)
(n, x) = list(map(int, input().split()))
a = list(map(int, input().split()))
Y = getIn10bySt(a, x)
if X > Y:
	print('>')
elif X < Y:
	print('<')
else:
	print('=')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
(l, k) = map(int, input().split())
b = list(map(int, input().split()))
c1 = 0
c2 = 0
for i in range(n - 1, -1, -1):
	c1 += m ** (n - 1 - i) * a[i]
for t in range(l - 1, -1, -1):
	c2 += k ** (l - 1 - t) * b[t]
if c1 == c2:
	print('=')
elif c1 < c2:
	print('<')
else:
	print('>')


(n, bx) = map(int, input().split())
x = list(map(int, input().split()))
(m, by) = map(int, input().split())
y = list(map(int, input().split()))
ax = 0
for (i, d) in enumerate(reversed(x)):
	ax += d * bx ** i
ay = 0
for (i, d) in enumerate(reversed(y)):
	ay += d * by ** i
if ax > ay:
	print('>')
elif ax < ay:
	print('<')
else:
	print('=')


x = input().split(' ')
n = int(x[0])
bx = int(x[1])
x = input().split(' ')
y = input().split(' ')
m = int(y[0])
by = int(y[1])
y = input().split(' ')
t = 1
X = 0
while n > 0:
	n -= 1
	X += t * int(x[n])
	t *= bx
t = 1
Y = 0
while m > 0:
	m -= 1
	Y += t * int(y[m])
	t *= by
if X == Y:
	print('=\n')
elif X < Y:
	print('<\n')
else:
	print('>\n')


def mp():
	return map(int, input().split())

def lt():
	return list(map(int, input().split()))

def pt(x):
	print(x)
(n, bx) = mp()
L = lt()
(m, by) = mp()
T = lt()
c = 0
while L != []:
	c *= bx
	c += L.pop(0)
b = 0
while T != []:
	b *= by
	b += T.pop(0)
if c > b:
	print('>')
elif c == b:
	print('=')
else:
	print('<')


z1 = list(map(int, input().split()))
x = list(map(int, input().split()))
z2 = list(map(int, input().split()))
y = list(map(int, input().split()))
(n1, b1) = (z1[0], z1[1])
(n2, b2) = (z2[0], z2[1])
ansx = ansy = 0
for i in range(n1):
	ansx += x[n1 - i - 1] * b1 ** i
for i in range(n2):
	ansy += y[n2 - i - 1] * b2 ** i
if ansx == ansy:
	print('=')
elif ansx > ansy:
	print('>')
else:
	print('<')


(n, bx) = map(int, input().split())
x = list(map(int, input().split()))
x = reversed(x)
q = 1
x1 = 0
for i in x:
	x1 += q * i
	q *= bx
(n, bx) = map(int, input().split())
x = list(map(int, input().split()))
x = reversed(x)
q = 1
y1 = 0
for i in x:
	y1 += q * i
	q *= bx
if x1 > y1:
	print('>')
elif x1 < y1:
	print('<')
else:
	print('=')


(n, b) = list(map(int, input().split(' ')))
X = list(map(int, input().split(' ')))
Nico = 1
x = 0
for i in range(n):
	x = x + X[n - 1 - i] * Nico
	Nico = Nico * b
(n, b) = list(map(int, input().split(' ')))
Y = list(map(int, input().split(' ')))
Nico = 1
y = 0
for i in range(n):
	y = y + Y[n - 1 - i] * Nico
	Nico = Nico * b
if x < y:
	print('<')
if x == y:
	print('=')
if x > y:
	print('>')


def get_number(digits, base):
	number = 0
	multiplier = 1
	for digit in reversed(digits):
		number += digit * multiplier
		multiplier *= base
	return number

def main():
	(n, b_x) = [int(t) for t in input().split()]
	digits_x = [int(t) for t in input().split()]
	(n, b_y) = [int(t) for t in input().split()]
	digits_y = [int(t) for t in input().split()]
	x = get_number(digits_x, b_x)
	y = get_number(digits_y, b_y)
	if x == y:
		print('=')
	if x < y:
		print('<')
	if x > y:
		print('>')
main()


(n, bx) = map(int, input().split())
X = list(map(int, input().split()))
(m, by) = map(int, input().split())
Y = list(map(int, input().split()))
(resX, resY) = (0, 0)
for i in range(n):
	resX += X[-i - 1] * bx ** i
for i in range(m):
	resY += Y[-i - 1] * by ** i
if resX < resY:
	print('<')
elif resX == resY:
	print('=')
else:
	print('>')


(n, bx) = list(map(int, input().split()))
x = []
x = list(map(int, input().split()))
(m, by) = list(map(int, input().split()))
y = []
y = list(map(int, input().split()))
xk = 1
yk = 1
X = 0
Y = 0
for i in range(n - 1, -1, -1):
	X += xk * x[i]
	xk *= bx
for i in range(m - 1, -1, -1):
	Y += yk * y[i]
	yk *= by
if X < Y:
	print('<')
if X > Y:
	print('>')
if X == Y:
	print('=')


(n, x) = map(int, input().split())
nX = [int(s) for s in input().split()]
(m, y) = map(int, input().split())
mY = [int(s) for s in input().split()]
sum = 0
for i in range(max(n, m)):
	if i < n:
		sum += nX[i] * x ** (n - 1 - i)
	if i < m:
		sum -= mY[i] * y ** (m - 1 - i)
if sum > 0:
	print('>')
elif sum < 0:
	print('<')
else:
	print('=')


def solve():
	(n, b_x) = map(int, input().split())
	x = [int(_) for _ in input().split()]
	(m, b_y) = map(int, input().split())
	y = [int(_) for _ in input().split()]
	x_result = 0
	for i in range(0, n):
		x_result += pow(b_x, i) * int(x[len(x) - 1 - i])
	y_result = 0
	for i in range(0, m):
		y_result += pow(b_y, i) * int(y[len(y) - 1 - i])
	if x_result > y_result:
		print('>')
	elif x_result < y_result:
		print('<')
	else:
		print('=')
solve()


(a1, b1) = map(int, input().split())
x = list(map(int, input().split()))
x1 = 0
(a2, b2) = map(int, input().split())
y = list(map(int, input().split()))
y1 = 0
for i in range(a1):
	x1 += b1 ** (a1 - i - 1) * x[i]
for i in range(a2):
	y1 += b2 ** (a2 - i - 1) * y[i]
if x1 < y1:
	print('<')
if x1 == y1:
	print('=')
if x1 > y1:
	print('>')


(nx, bx) = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
(ny, by) = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
resx = 0
resy = 0
for i in range(nx):
	resx += x[i] * bx ** (nx - i - 1)
for i in range(ny):
	resy += y[i] * by ** (ny - i - 1)
if resx > resy:
	print('>')
elif resx == resy:
	print('=')
else:
	print('<')


(n, bx) = map(int, input().split())
x = list(map(int, input().split()))
(m, by) = map(int, input().split())
y = list(map(int, input().split()))
xx = sum((v * bx ** (len(x) - i - 1) for (i, v) in enumerate(x)))
yy = sum((v * by ** (len(y) - i - 1) for (i, v) in enumerate(y)))
if xx < yy:
	print('<')
elif xx == yy:
	print('=')
else:
	print('>')


(n, b1) = map(int, input().split())
x = list(map(int, input().split()))[::-1]
(m, b2) = map(int, input().split())
y = list(map(int, input().split()))[::-1]
(sx, sy) = (0, 0)
for i in range(n):
	sx += b1 ** i * x[i]
for j in range(m):
	sy += b2 ** j * y[j]
if sx == sy:
	print('=')
else:
	print('<' if sx < sy else '>')


I = lambda : map(int, input().split())
(n, b) = I()
X = sum((x * b ** (n - i) for (i, x) in enumerate(I(), 1)))
(n, b) = I()
Y = sum((y * b ** (n - i) for (i, y) in enumerate(I(), 1)))
print('<' if X < Y else '>' if X > Y else '=')


def input_to_10():
	(n, base) = map(int, input().split())
	res = 0
	for el in map(int, input().split()):
		res = el + res * base
	return res
a = input_to_10()
b = input_to_10()
if a == b:
	print('=')
elif a < b:
	print('<')
else:
	print('>')


(n1, m1) = map(int, input().split())
s1 = 0
p = 1
for i in list(reversed(list(map(int, input().split())))):
	s1 += i * p
	p *= m1
(n1, m1) = map(int, input().split())
s2 = 0
p = 1
for i in list(reversed(list(map(int, input().split())))):
	s2 += i * p
	p *= m1
if s1 == s2:
	print('=')
elif s1 > s2:
	print('>')
else:
	print('<')


(n, b) = map(int, input().split())
x = list(map(int, input().split()))
(m, c) = map(int, input().split())
y = list(map(int, input().split()))
x = x[::-1]
y = y[::-1]
X = 0
Y = 0
for i in range(len(x)):
	X += x[i] * b ** i
for i in range(len(y)):
	Y += y[i] * c ** i
if X == Y:
	print('=')
elif X < Y:
	print('<')
else:
	print('>')


(nx, bx) = map(int, input().split())
ar_x = list(map(int, input().split()))
(ny, by) = map(int, input().split())
ar_y = list(map(int, input().split()))
(ans_y, ans_x) = (0, 0)
cnt = 0
for i in ar_y[::-1]:
	ans_y = ans_y + i * by ** cnt
	cnt += 1
cnt = 0
for i in ar_x[::-1]:
	ans_x = ans_x + i * bx ** cnt
	cnt += 1
if ans_x == ans_y:
	print('=')
elif ans_x < ans_y:
	print('<')
else:
	print('>')


(n, bx) = input().split()
bx = int(bx)
x = input()
a = [int(i) for i in x.split()]
(m, by) = input().split()
by = int(by)
y = input()
b = [int(i) for i in y.split()]
vbx = 0
for i in range(len(a)):
	vbx = vbx + bx ** (len(a) - i - 1) * a[i]
vby = 0
for i in range(len(b)):
	vby = vby + by ** (len(b) - i - 1) * b[i]
if vbx < vby:
	print('<')
elif vbx == vby:
	print('=')
else:
	print('>')


ar = [0, 0]
for i in range(0, 2):
	[n, b] = [int(x) for x in input().split()]
	for x in [int(x) for x in input().split()]:
		ar[i] *= b
		ar[i] += x
if ar[0] == ar[1]:
	print('=')
elif ar[0] > ar[1]:
	print('>')
else:
	print('<')


(n, bx) = list(map(int, input().split()))
x1 = list(map(int, input().split()))
x = 0
for i in range(n):
	x *= bx
	x += x1[i]
(n, by) = list(map(int, input().split()))
y1 = list(map(int, input().split()))
y = 0
for i in range(n):
	y *= by
	y += y1[i]
if x == y:
	print('=')
elif x < y:
	print('<')
else:
	print('>')


(basamak1, taban1) = list(map(int, input().split()))
ilksayi = list(map(int, input().split()))
(basamak2, taban2) = list(map(int, input().split()))
ikisayi = list(map(int, input().split()))
tot1 = 0
tot2 = 0
for i in range(1, basamak1 + 1):
	tot1 += ilksayi[-i] * taban1 ** (i - 1)
for i in range(1, basamak2 + 1):
	tot2 += ikisayi[-i] * taban2 ** (i - 1)
if tot1 == tot2:
	print('=')
elif tot1 > tot2:
	print('>')
else:
	print('<')


from math import *
(n, x) = map(int, input().split())
a = list(map(int, input().split()))
(m, y) = map(int, input().split())
b = list(map(int, input().split()))
a.reverse()
b.reverse()
res1 = 0
for i in range(len(a)):
	res1 += int(a[i]) * x ** i
res2 = 0
for i in range(len(b)):
	res2 += int(b[i]) * y ** i
if res1 == res2:
	print('=')
	quit()
if res1 < res2:
	print('<')
	quit()
print('>')


(n, nb) = map(int, input().split())
nl = list(map(int, input().split()))
(m, mb) = map(int, input().split())
ml = list(map(int, input().split()))
x = 0
y = 0
for i in nl:
	x = x * nb + i
for i in ml:
	y = y * mb + i
if x == y:
	print('=')
elif x > y:
	print('>')
else:
	print('<')


(n, bx) = input().split()
(n, bx) = (int(n), int(bx))
d = input().split()
(x, pot) = (0, 1)
d.reverse()
for dd in d:
	x += int(dd) * pot
	pot *= bx
(n, bx) = input().split()
(n, bx) = (int(n), int(bx))
d = input().split()
(y, pot) = (0, 1)
d.reverse()
for dd in d:
	y += int(dd) * pot
	pot *= bx
if x < y:
	print('<')
elif x > y:
	print('>')
else:
	print('=')


def func(x, arr):
	arr = list(map(int, arr))
	arr.reverse()
	num = 0
	b = 1
	for i in arr:
		num = num + b * i
		b = b * x
	return num
inp = input().split()
inp = list(map(int, inp))
(n, m) = inp
arr = input().split()
n1 = func(m, arr)
inp = input().split()
inp = list(map(int, inp))
(n, m) = inp
arr = input().split()
n2 = func(m, arr)
if n1 < n2:
	print('<')
elif n1 == n2:
	print('=')
else:
	print('>')


n = list(map(int, input().split()))
num1 = list(map(int, input().split()))
t1 = 0
x = n[0]
for i in range(0, n[0]):
	x -= 1
	t1 += num1[i] * pow(n[1], x)
m = list(map(int, input().split()))
num2 = list(map(int, input().split()))
t2 = 0
y = m[0]
for i in range(0, m[0]):
	y -= 1
	t2 += num2[i] * pow(m[1], y)
if t1 == t2:
	print('=')
elif t1 > t2:
	print('>')
else:
	print('<')


import math
s1 = input()
s2 = input()
s3 = input()
s4 = input()
dx = int(s1.split(' ')[0])
bx = int(s1.split(' ')[1])
dy = int(s3.split(' ')[0])
by = int(s3.split(' ')[1])
x = 0
y = 0
for i in range(0, dx):
	x = x + int(s2.split(' ')[i]) * bx ** (dx - 1 - i)
for i in range(0, dy):
	y = y + int(s4.split(' ')[i]) * by ** (dy - 1 - i)
if x < y:
	print('<')
elif x > y:
	print('>')
else:
	print('=')


(nx, bx) = map(int, input().split())
A = list(map(int, input().split()))
(ny, by) = map(int, input().split())
B = list(map(int, input().split()))
x = y = 0
for i in range(len(A)):
	x = x * bx + A[i]
for i in range(len(B)):
	y = y * by + B[i]
if x > y:
	print('>')
elif x < y:
	print('<')
else:
	print('=')


import sys
input = sys.stdin.readline

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
(nb, xb) = int_array()
b = int_array()
(na, xa) = int_array()
a = int_array()
bval = aval = 0
for i in range(nb):
	x = xb ** i * b[nb - i - 1]
	bval += x
for i in range(na):
	x = xa ** i * a[na - i - 1]
	aval += x
if bval < aval:
	print('<')
elif bval > aval:
	print('>')
else:
	print('=')


i = input()
(n, bx) = tuple(map(int, i.split(' ')))
i = input()
val1 = sum([int(a) * bx ** (n - ind - 1) for (ind, a) in enumerate(i.split(' '))])
i = input()
(n, bx) = tuple(map(int, i.split(' ')))
i = input()
val2 = sum([int(a) * bx ** (n - ind - 1) for (ind, a) in enumerate(i.split(' '))])
if val1 == val2:
	print('=')
elif val1 < val2:
	print('<')
else:
	print('>')


(n, x) = list(map(int, input().split()))
a = list(map(int, input().split()))
v = 0
u = 0
for d in a:
	v = v * x + d
(n, x) = list(map(int, input().split()))
a = list(map(int, input().split()))
for d in a:
	u = u * x + d
if v == u:
	print('=')
if v < u:
	print('<')
if v > u:
	print('>')


def f(a, x):
	n = len(a)
	res = 0
	for i in range(n):
		res += a[i] * x ** (n - i - 1)
	return res
(n, bx) = map(int, input().split())
a = list(map(int, input().split()))
res1 = f(a, bx)
(n, bx) = map(int, input().split())
a = list(map(int, input().split()))
res2 = f(a, bx)
if res1 == res2:
	print('=')
elif res1 > res2:
	print('>')
else:
	print('<')


(n, n1) = map(int, input().split())
a = [int(x) for x in input().split()]
(m, m1) = map(int, input().split())
b = [int(x) for x in input().split()]
s1 = 0
s2 = 0
k = 0
for i in range(len(a) - 1, -1, -1):
	s1 += a[i] * n1 ** k
	k += 1
k = 0
for i in range(len(b) - 1, -1, -1):
	s2 += b[i] * m1 ** k
	k += 1
if s1 < s2:
	print('<')
elif s1 > s2:
	print('>')
else:
	print('=')


__author__ = 'MoonBall'
import sys
T = 1

def t():
	(N, A) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = 0
	for v in a:
		ans = ans * A + v
	return ans

def process():
	X = t()
	Y = t()
	print('=' if X == Y else '<' if X < Y else '>')
for _ in range(T):
	process()


import math

def baseCompare():
	baseXInfo = input().split()
	baseXDigits = input().split()
	baseYInfo = input().split()
	baseYDigits = input().split()
	actualX = 0
	for power in range(int(baseXInfo[0])):
		actualX += pow(int(baseXInfo[1]), int(baseXInfo[0]) - power - 1) * int(baseXDigits[power])
	actualY = 0
	for power in range(int(baseYInfo[0])):
		actualY += pow(int(baseYInfo[1]), int(baseYInfo[0]) - power - 1) * int(baseYDigits[power])
	if actualX == actualY:
		print('=')
	elif actualX > actualY:
		print('>')
	else:
		print('<')
baseCompare()


R = lambda : map(int, input().split())

def get_num():
	(n, b) = R()
	v = list(R())[::-1]
	i = 1
	num = 0
	for _ in range(len(v)):
		num += i * v[_]
		i *= b
	return num
x = get_num()
y = get_num()
if x > y:
	print('>')
elif x == y:
	print('=')
else:
	print('<')


(n, bx) = map(int, input().split())
x = list(map(int, input().split()))
(m, by) = map(int, input().split())
y = list(map(int, input().split()))
tmp = 1
ans = 0
for i in range(1, n + 1):
	ans += x[-i] * tmp
	tmp *= bx
ans1 = 0
tmp = 1
for i in range(1, m + 1):
	ans1 += y[-i] * tmp
	tmp *= by
if ans < ans1:
	print('<')
elif ans > ans1:
	print('>')
else:
	print('=')


x = 0
(n, k) = map(int, input().split())
for i in map(int, input().split()):
	n -= 1
	x += i * k ** n
y = 0
(n, k) = map(int, input().split())
for i in map(int, input().split()):
	n -= 1
	y += i * k ** n
print('=' if x == y else '<' if x < y else '>')


def f(nums, base):
	num = 0
	for j in range(len(nums)):
		num *= base
		num += nums[j]
	return num
(n, b1) = [int(j) for j in input().split()]
x = [int(j) for j in input().split()]
(m, b2) = [int(j) for j in input().split()]
y = [int(j) for j in input().split()]
(n1, n2) = (f(x, b1), f(y, b2))
if n1 < n2:
	print('<')
elif n1 > n2:
	print('>')
else:
	print('=')


def calc():
	(n, b) = map(int, input().split())
	x = list(map(int, input().split()))
	ans = 0
	for i in x:
		ans = ans * b + i
	return ans
X = calc()
Y = calc()
if X > Y:
	print('>')
elif X == Y:
	print('=')
else:
	print('<')


withFile = 0
if withFile == 1:
	fin = open('input.txt', 'r')
	fout = open('output.txt', 'w')

def getl():
	if withFile == 0:
		return input()
	else:
		return fin.readline()

def printl(s):
	if withFile == 0:
		print(s)
	else:
		fout.write(str(s))

def get_arr():
	x = getl().split(' ')
	if x[-1] == '':
		x = x[:-1]
	return list(map(int, x))
(n, bx) = get_arr()
x = get_arr()
(m, by) = get_arr()
y = get_arr()
xx = yy = 0
for c in x:
	xx *= bx
	xx += c
for c in y:
	yy *= by
	yy += c
if xx < yy:
	printl('<')
elif xx == yy:
	printl('=')
else:
	printl('>')
if withFile == 1:
	fin.close()
	fout.close()


firstline = [int(x) for x in input().split()]
firstnum = 0
for digit in input().split():
	firstnum *= firstline[1]
	firstnum += int(digit)
secondline = [int(x) for x in input().split()]
secondnum = 0
for digit in input().split():
	secondnum *= secondline[1]
	secondnum += int(digit)
if firstnum > secondnum:
	print('>')
if firstnum == secondnum:
	print('=')
if firstnum < secondnum:
	print('<')


(n, bx) = [int(x) for x in input().split()]
xi = [int(x) for x in input().split()]
(m, by) = [int(x) for x in input().split()]
yi = [int(x) for x in input().split()]
x = 0
y = 0
for i in range(len(xi)):
	x += xi[i] * bx ** (n - i - 1)
for i in range(len(yi)):
	y += yi[i] * by ** (m - i - 1)
if x == y:
	print('=')
if x > y:
	print('>')
if x < y:
	print('<')


(n, b1) = map(int, input().split())
arr1 = list(map(int, input().split()))
(m, b2) = map(int, input().split())
arr2 = list(map(int, input().split()))
sum1 = 0
sum2 = 0
for i in arr1:
	sum1 += i * b1 ** (n - 1)
	n -= 1
for i in arr2:
	sum2 += i * b2 ** (m - 1)
	m -= 1
if sum1 == sum2:
	print('=')
elif sum1 < sum2:
	print('<')
else:
	print('>')


def calc(base, arr):
	n = len(arr)
	ans = 0
	for i in range(0, n):
		ans = ans + base ** i * arr[-1 - i]
	return ans
info = list(map(int, input().split()))
(sizex, basex) = (info[0], info[1])
valx = list(map(int, input().split()))
info = list(map(int, input().split()))
(sizey, basey) = (info[0], info[1])
valy = list(map(int, input().split()))
one = calc(basex, valx)
two = calc(basey, valy)
if one == two:
	print('=')
elif one < two:
	print('<')
elif one > two:
	print('>')


(a, b) = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
(d, e) = [int(i) for i in input().split()]
f = [int(i) for i in input().split()]
x = 0
y = 0
for i in range(a):
	x += c[i] * b ** (a - i - 1)
for i in range(d):
	y += f[i] * e ** (d - i - 1)
if x > y:
	print('>')
elif x < y:
	print('<')
else:
	print('=')


import os
(n, bx) = map(int, input().split())
x = 0
lx = []
t = input()
for i in t.split():
	lx.append(int(i))
for i in range(0, n):
	x = x * bx + lx[i]
(m, by) = map(int, input().split())
y = 0
ly = []
t = input()
for i in t.split():
	ly.append(int(i))
for i in range(0, m):
	y = y * by + ly[i]
if x > y:
	print('>')
elif x < y:
	print('<')
else:
	print('=')


f = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
s = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
bx = f.pop()
nx = f.pop()
by = s.pop()
ny = s.pop()
xreal = 0
yreal = 0
if bx == 10:
	xreal = ''
	for num in x:
		xreal += str(num)
	xreal = int(xreal)
else:
	k = len(x)
	count = 1
	for num in x:
		xreal += num * bx ** (k - count)
		count += 1
if by == 10:
	yreal = ''
	for num in y:
		yreal += str(num)
	yreal = int(yreal)
else:
	k = len(y)
	count = 1
	for num in y:
		yreal += num * by ** (k - count)
		count += 1
if xreal == yreal:
	print('=')
elif xreal > yreal:
	print('>')
else:
	print('<')


infox = input().split(' ')
nx = int(infox[0])
bx = int(infox[1])
x = input().split(' ')
infoy = input().split(' ')
ny = int(infoy[0])
by = int(infoy[1])
y = input().split(' ')
sumx = 0
sumy = 0
for i in range(nx):
	sumx = sumx * bx + int(x[i])
for i in range(ny):
	sumy = sumy * by + int(y[i])
if sumx > sumy:
	print('>')
elif sumx == sumy:
	print('=')
else:
	print('<')


(n, x) = map(int, input().split())
l = list(map(int, input().split()))
(m, y) = map(int, input().split())
d = list(map(int, input().split()))
(l, d) = (l[::-1], d[::-1])
(c, ka) = (0, 0)
for i in range(n):
	c = c + pow(x, i) * l[i]
for i in range(m):
	ka = ka + pow(y, i) * d[i]
if ka > c:
	print('<')
elif ka < c:
	print('>')
else:
	print('=')


contest = True
if not contest:
	fin = open('in', 'r')
inp = input if contest else lambda : fin.readline()[:-1]
read = lambda : tuple(map(int, inp().split()))
(lx, bx) = read()
numsx = tuple(reversed(read()))
x = 0
for i in range(lx):
	x += numsx[i] * bx ** i
(ly, by) = read()
numsy = tuple(reversed(read()))
y = 0
for i in range(ly):
	y += numsy[i] * by ** i
if x == y:
	print('=')
if x > y:
	print('>')
if x < y:
	print('<')


(n, bx) = list(map(int, input().split(' ')))
X = list(map(int, input().split(' ')))
(m, by) = list(map(int, input().split(' ')))
Y = list(map(int, input().split(' ')))
vx = 0
vy = 0
for i in range(n - 1, -1, -1):
	vx += X[n - i - 1] * bx ** i
for i in range(m - 1, -1, -1):
	vy += Y[m - i - 1] * by ** i
if vx == vy:
	print('=')
elif vx > vy:
	print('>')
else:
	print('<')


(n, a) = input().split()
n = int(n)
x = 0
p = 1
a = int(a)
l = input().split()
for i in range(n):
	x += int(l[n - i - 1]) * p
	p *= a
(n, b) = input().split()
n = int(n)
y = 0
p = 1
b = int(b)
l = input().split()
for i in range(n):
	y += int(l[n - i - 1]) * p
	p *= b
if x == y:
	print('=')
elif x < y:
	print('<')
else:
	print('>')


(n, bx) = [int(i) for i in input().split(' ')]
x = [int(i) for i in input().split(' ')]
(m, by) = [int(i) for i in input().split(' ')]
y = [int(i) for i in input().split(' ')]
xx = 0
for i in x:
	xx *= bx
	xx += i
yy = 0
for i in y:
	yy *= by
	yy += i
if xx == yy:
	print('=')
elif xx < yy:
	print('<')
else:
	print('>')


I = lambda : map(int, input().split()[::-1])

def f():
	(b, _) = I()
	(r, x) = (0, 1)
	for i in I():
		r += i * x
		x *= b
	return r
a = f() - f()
print('<' if a < 0 else '>='[a == 0])


def get():
	a = [int(x) for x in input().split()]
	d = 0
	for x in input().split():
		d = d * a[1] + int(x)
	return d
dg = get()
dg2 = get()
if dg == dg2:
	print('=')
elif dg > dg2:
	print('>')
else:
	print('<')


(n, bx) = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
(m, by) = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
(xd, yd) = (0, 0)
for i in range(n):
	xd += x[i] * bx ** (n - i - 1)
for i in range(m):
	yd += y[i] * by ** (m - i - 1)
if xd < yd:
	print('<')
elif xd > yd:
	print('>')
else:
	print('=')


(n, b) = list(map(int, input().split()))
l1 = list(reversed(list(map(int, input().split()))))
(m, a) = list(map(int, input().split()))
l2 = list(reversed(list(map(int, input().split()))))
x = 0
y = 0
for i in range(len(l1)):
	x += l1[i] * pow(b, i)
for i in range(len(l2)):
	y += l2[i] * pow(a, i)
if x < y:
	print('<')
elif x == y:
	print('=')
else:
	print('>')


(n, bx) = map(int, input().split())
inp = list(map(int, input().split()))
num1 = sum((inp[i] * bx ** (n - i - 1) for i in range(n)))
(m, by) = map(int, input().split())
inp = list(map(int, input().split()))
num2 = sum((inp[i] * by ** (m - i - 1) for i in range(m)))
if num1 == num2:
	print('=')
elif num1 < num2:
	print('<')
else:
	print('>')


import sys
(n, bx) = map(int, input().split())
x = list(map(int, input().split()))
(m, by) = map(int, input().split())
y = list(map(int, input().split()))
res1 = res2 = 0
a = b = 0
for i in range(n - 1, -1, -1):
	res1 += x[i] * bx ** a
	a += 1
for j in range(m - 1, -1, -1):
	res2 += y[j] * by ** b
	b += 1
if res1 < res2:
	print('<')
elif res1 > res2:
	print('>')
else:
	print('=')


def conv(a, x):
	h = 1
	ans = 0
	a.reverse()
	for i in a:
		ans += h * i
		h = h * x
	return ans

def main():
	mode = 'filee'
	if mode == 'file':
		f = open('test.txt', 'r')
	get = lambda : [int(x) for x in (f.readline() if mode == 'file' else input()).split()]
	[n, x] = get()
	a = get()
	[m, y] = get()
	b = get()
	a = conv(a, x)
	b = conv(b, y)
	if a == b:
		print('=')
	elif a < b:
		print('<')
	else:
		print('>')
	if mode == 'file':
		f.close()
main()


import sys
(a, b) = map(int, input().split())
c = list(map(int, input().split()))
(d, e) = map(int, input().split())
f = list(map(int, input().split()))
c.reverse()
f.reverse()
s1 = s2 = 0
for i in range(0, a):
	s1 += c[i] * b ** i
for i in range(0, d):
	s2 += f[i] * e ** i
if s1 < s2:
	sys.stdout.write('<')
elif s1 > s2:
	sys.stdout.write('>')
else:
	sys.stdout.write('=')


(n, bx) = map(int, input().split())
x = list(map(int, input().split()))
(m, by) = map(int, input().split())
y = list(map(int, input().split()))
r = 0
for i in x:
	r *= bx
	r += i
R = 0
for i in y:
	R *= by
	R += i
if r == R:
	print('=')
else:
	print(['>', '<'][r < R])


def to_dec(s, b):
	i = len(s) - 1
	n = 0
	for d in s:
		n += d * b ** i
		i -= 1
	return n
(xlen, xb) = map(int, input().split())
x = list(map(int, input().split()))
(ylen, yb) = map(int, input().split())
y = list(map(int, input().split()))
x = int(to_dec(x, xb))
y = int(to_dec(y, yb))
if x == y:
	print('=')
elif x > y:
	print('>')
else:
	print('<')


def main():
	(n, bx) = (int(x) for x in input().split())
	digitsX = [int(x) for x in input().split()]
	(m, by) = (int(x) for x in input().split())
	digitsY = [int(x) for x in input().split()]
	print(solver(digitsX, bx, digitsY, by))

def solver(digitsX, bx, digitsY, by):
	X = getValue(digitsX, bx)
	Y = getValue(digitsY, by)
	if X < Y:
		return '<'
	elif X == Y:
		return '='
	else:
		return '>'

def getValue(digitsK, bk):
	total = 0
	for i in range(len(digitsK)):
		total += digitsK[i] * pow(bk, len(digitsK) - i - 1)
	return total
main()


ans = []
for i in range(2):
	((n, b), data) = (map(int, input().split()), list(map(int, input().split())))
	data.reverse()
	t = 0
	j = 0
	for i in range(n):
		t += data[i] * b ** j
		j += 1
	ans.append(t)
if ans[0] > ans[1]:
	print('>')
elif ans[0] < ans[1]:
	print('<')
else:
	print('=')


def num():
	(a, b) = map(int, input().split())
	n = 0
	for i in map(int, input().split()):
		n = n * b + i
	return n
n1 = num()
n2 = num()
if n1 == n2:
	print('=')
elif n1 > n2:
	print('>')
else:
	print('<')


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)])


(n, b) = map(int, input().split())
l = list(map(int, input().split()))
d = 1
a1 = b1 = 0
for x in range(n - 1, -1, -1):
	a1 += l[x] * d
	d *= b
(m, a) = map(int, input().split())
l = list(map(int, input().split()))
d = 1
for x in range(m - 1, -1, -1):
	b1 += l[x] * d
	d *= a
if a1 == b1:
	print('=')
elif a1 > b1:
	print('>')
else:
	print('<')


def digits_to_int(b, ds):
	i = 0
	for d in ds:
		i = i * b + d
	return i

def compare(bx, xd, by, yd):
	x = digits_to_int(bx, xd)
	y = digits_to_int(by, yd)
	return '<' if x < y else '>' if x > y else '='
(n, bx) = map(int, input().split())
xd = tuple(map(int, input().split()))
(m, by) = map(int, input().split())
yd = tuple(map(int, input().split()))
print(compare(bx, xd, by, yd))


(n, bx) = [int(i) for i in input().split(' ')]
arr = [int(i) for i in input().split(' ')]
ans1 = 0
pw = bx ** (n - 1)
for i in arr:
	ans1 += i * pw
	pw //= bx
(n, bx) = [int(i) for i in input().split(' ')]
arr = [int(i) for i in input().split(' ')]
ans2 = 0
pw = bx ** (n - 1)
for i in arr:
	ans2 += i * pw
	pw //= bx
if ans1 == ans2:
	print('=')
elif ans1 > ans2:
	print('>')
else:
	print('<')


x = [int(e) for e in input().split(' ')]
x1 = [int(t) for t in input().split(' ')]
y = [int(w) for w in input().split(' ')]
y1 = [int(q) for q in input().split(' ')]
indx1 = len(x1) - 1
indy1 = len(y1) - 1
basex = x[1]
basey = y[1]
lx = x[0]
ly = y[0]
somx = 0
somy = 0
k = 0
h = 0
while lx > 0:
	somx += x1[indx1] * x[1] ** k
	indx1 -= 1
	k += 1
	lx -= 1
while ly > 0:
	somy += y1[indy1] * y[1] ** h
	indy1 -= 1
	h += 1
	ly -= 1
if somx == somy:
	print('=')
elif somx > somy:
	print('>')
elif somx < somy:
	print('<')
else:
	pass


(n, bx) = map(int, input().split())
(X, Y) = (0, 0)
for x in list(map(int, input().split())):
	X = X * bx + x
(n, by) = map(int, input().split())
for y in list(map(int, input().split())):
	Y = Y * by + y
print([['<', '>'][X > Y], '='][X == Y])


(n, a) = map(int, input().split())
X = [0] + [int(x) for x in input().split()]
(m, b) = map(int, input().split())
Y = [0] + [int(x) for x in input().split()]
(num1, num2) = (0, 0)
for x in range(1, len(X)):
	num1 += X[x] * pow(a, n - x)
for y in range(1, len(Y)):
	num2 += Y[y] * pow(b, m - y)
if num1 < num2:
	print('<')
elif num1 > num2:
	print('>')
else:
	print('=')


(n, bx) = [int(x) for x in input().strip().split()]
X = [int(x) for x in input().strip().split()]
NX = 0
for (idx, x) in enumerate(X):
	NX *= bx
	NX += x
(m, by) = [int(x) for x in input().strip().split()]
Y = [int(x) for x in input().strip().split()]
NY = 0
for (idx, x) in enumerate(Y):
	NY *= by
	NY += x
if NX == NY:
	print('=')
elif NX > NY:
	print('>')
else:
	print('<')


def read():
	(n, b) = map(int, input().split())
	t = 0
	l = list(map(int, input().split()))
	for i in l:
		t = t * b + i
	return t
a = read()
b = read()
if a == b:
	print('=')
elif a < b:
	print('<')
else:
	print('>')


(n, b) = map(int, input().split())
a = list(map(int, input().split()))
x = 0
for i in range(n):
	x += a[i] * b ** (n - i - 1)
(n, b) = map(int, input().split())
a = list(map(int, input().split()))
y = 0
for i in range(n):
	y += a[i] * b ** (n - i - 1)
if x == y:
	print('=')
elif x < y:
	print('<')
else:
	print('>')


__author__ = 'sandeepmellacheruvu'
(nx, bx) = map(int, input().split())
x = list(map(int, input().split()))
(ny, by) = map(int, input().split())
y = list(map(int, input().split()))
numX = 0
numY = 0
for i in range(len(x)):
	numX += x[i] * bx ** (len(x) - i - 1)
for i in range(len(y)):
	numY += y[i] * by ** (len(y) - i - 1)
if numX < numY:
	print('<')
elif numX > numY:
	print('>')
else:
	print('=')


__author__ = 'cmashinho'
(n, b) = map(int, input().split())
lB = list(map(int, input().split()))
(m, y) = map(int, input().split())
lY = list(map(int, input().split()))
nB = 0
nY = 0
for i in range(n):
	nB += lB[i] * int(pow(b, n - i - 1))
for i in range(m):
	nY += lY[i] * int(pow(y, m - i - 1))
if nB == nY:
	print('=')
elif nB > nY:
	print('>')
else:
	print('<')


def f(a, b, c):
	ret = 0
	mult = 1
	for i in range(a - 1, -1, -1):
		ret += int(c[i]) * mult
		mult = mult * b
	return ret
a1 = input().split()
c1 = input().split()
a2 = input().split()
c2 = input().split()
x = f(int(a1[0]), int(a1[1]), c1)
y = f(int(a2[0]), int(a2[1]), c2)
if y == x:
	print('=')
elif x < y:
	print('<')
else:
	print('>')


from itertools import count
from operator import mul

def ints():
	return [int(x) for x in input().split()]

def number():
	((n, base), digits) = (ints(), ints())
	powers = (base ** i for i in range(n - 1, -1, -1))
	return sum((d * p for (d, p) in zip(digits, powers)))
(X, Y) = (number(), number())
print('>' if X > Y else '<' if X < Y else '=')


(a1, b1) = map(int, input().split())
X = input().split()
(a2, b2) = map(int, input().split())
Y = input().split()
k = 0
g = 0
for i in range(a1):
	k += int(X[i]) * b1 ** (a1 - i - 1)
for i in range(a2):
	g += int(Y[i]) * b2 ** (a2 - i - 1)
if k > g:
	print('>')
elif k < g:
	print('<')
elif k == g:
	print('=')


def convert(digits, base):
	res = 0
	digits.reverse()
	power = 1
	for i in digits:
		res += i * power
		power *= base
	return res
(n, base_a) = [int(x) for x in input().split()]
digits_a = [int(x) for x in input().split()]
a = convert(digits_a, base_a)
(n, base_a) = [int(x) for x in input().split()]
digits_a = [int(x) for x in input().split()]
b = convert(digits_a, base_a)
if a < b:
	print('<')
elif a > b:
	print('>')
else:
	print('=')


(digit1, base1) = input().split()
data = input().split()
data = [int(x) for x in data]
data = data[::-1]
out = 0
power = 0
for i in data:
	out += i * int(base1) ** power
	power += 1
(digit2, base2) = input().split()
data2 = input().split()
data2 = [int(x) for x in data2]
data2 = data2[::-1]
power = 0
out2 = 0
for i in data2:
	out2 += i * int(base2) ** power
	power += 1
if out == out2:
	print('=')
elif out < out2:
	print('<')
elif out > out2:
	print('>')


(n, bx) = [int(i) for i in input().split()]
x = input().split()
s = 0
for i in range(n):
	s = s + int(x[i]) * bx ** (n - i - 1)
(m, by) = [int(i) for i in input().split()]
y = input().split()
t = 0
for i in range(m):
	t = t + int(y[i]) * by ** (m - i - 1)
if s < t:
	print('<')
if s == t:
	print('=')
if s > t:
	print('>')


(n, x) = map(int, input().split())
bx = list(input().split())
(m, y) = map(int, input().split())
by = list(input().split())
nx = 0
p = n - 1
for i in bx:
	nx += x ** p * int(i)
	p -= 1
p = m - 1
my = 0
for i in by:
	my += y ** p * int(i)
	p -= 1
if nx < my:
	print('<')
if nx > my:
	print('>')
if nx == my:
	print('=')


def base(a, b, c):
	tot = 0
	for i in range(a):
		tot += c[-(i + 1)] * b ** i
	return tot
(x, bx) = (int(i) for i in input().split())
xnum = [int(i) for i in input().split()]
(y, by) = (int(i) for i in input().split())
ynum = [int(i) for i in input().split()]
rx = base(x, bx, xnum)
ry = base(y, by, ynum)
if rx == ry:
	print('=')
elif rx > ry:
	print('>')
else:
	print('<')


def main():
	res = []
	for _ in range(2):
		(_, b) = map(int, input().split())
		x = 0
		for s in input().split():
			x = x * b + int(s)
		res.append(x)
	print('>' if res[0] > res[1] else '<' if res[0] < res[1] else '=')
main()


(n, b1) = map(int, input().split())
num = [int(x) for x in input().split()]
p = b1 ** (n - 1)
x = 0
for i in range(n):
	numx = int(num[i])
	x += numx * p
	p //= b1
(m, b2) = map(int, input().split())
num = [int(x) for x in input().split()]
p = b2 ** (m - 1)
y = 0
for i in range(m):
	numy = int(num[i])
	y += numy * p
	p //= b2
if x < y:
	print('<')
elif x > y:
	print('>')
else:
	print('=')


(_, b) = map(int, input().split())
one = 0
for i in [int(x) for x in input().split()]:
	one = one * b + i
(_, b) = map(int, input().split())
two = 0
for i in [int(x) for x in input().split()]:
	two = two * b + i
if one < two:
	print('<')
if one > two:
	print('>')
if one == two:
	print('=')


[n, bx] = [int(i) for i in input().split()]
xs = [int(i) for i in input().split()]
bx_pow = 1
x = 0
for xi in xs[::-1]:
	x += bx_pow * xi
	bx_pow *= bx
[m, by] = [int(i) for i in input().split()]
ys = [int(i) for i in input().split()]
by_pow = 1
y = 0
for yi in ys[::-1]:
	y += by_pow * yi
	by_pow *= by
if x < y:
	print('<')
elif x > y:
	print('>')
else:
	print('=')


def make_num(lst, osn):
	result = 0
	for elem in lst:
		result *= osn
		result += elem
	return result
(n, bx) = [int(i) for i in input().split()]
num1 = make_num(map(int, input().split()), bx)
(m, by) = [int(i) for i in input().split()]
num2 = make_num(map(int, input().split()), by)
if num1 < num2:
	print('<')
elif num1 == num2:
	print('=')
else:
	print('>')


Answer = []
for i in range(2):
	Temp = list(map(int, input().split()))
	Num = list(map(int, input().split()))[::-1]
	Answer.append(sum([Num[i] * Temp[1] ** i for i in range(Temp[0])]))
print('=' if Answer[1] == Answer[0] else '<' if Answer[0] < Answer[1] else '>')


(n, b) = map(int, input().split())
curr = 1
c1 = 0
a = [int(i) for i in input().split()]
a = a[::-1]
for i in range(n):
	c1 += a[i] * curr
	curr *= b
(n, b) = map(int, input().split())
curr = 1
c2 = 0
a = [int(i) for i in input().split()]
a = a[::-1]
for i in range(n):
	c2 += a[i] * curr
	curr *= b
if c1 < c2:
	print('<')
elif c1 == c2:
	print('=')
else:
	print('>')


import sys

def getN():
	(n, base) = map(int, sys.stdin.readline().split())
	x = list(map(int, sys.stdin.readline().split()))
	b = 1
	ans = 0
	for xi in x[::-1]:
		ans += xi * b
		b *= base
	return ans
X = getN()
Y = getN()
if X < Y:
	print('<')
elif X > Y:
	print('>')
else:
	print('=')


import math
from decimal import *
import sys
from fractions import Fraction
inp = input().split()
n = int(inp[0])
bx = int(inp[1])
X = list(map(int, input().split()))
inp = input().split()
m = int(inp[0])
by = int(inp[1])
Y = list(map(int, input().split()))
x = 0
t = 1
for i in range(0, n):
	x += X[n - i - 1] * t
	t *= bx
y = 0
t = 1
for i in range(0, m):
	y += Y[m - i - 1] * t
	t *= by
if x < y:
	print('<')
if x == y:
	print('=')
if x > y:
	print('>')


(n, b1) = map(int, input().split())
x = list(map(int, input().split()))
(m, b2) = map(int, input().split())
y = list(map(int, input().split()))
x = x[::-1]
y = y[::-1]
ans1 = 0
for i in range(n):
	ans1 += b1 ** i * x[i]
ans2 = 0
for i in range(m):
	ans2 += b2 ** i * y[i]
if ans1 == ans2:
	print('=')
elif ans1 < ans2:
	print('<')
else:
	print('>')


h = []
for i in range(2):
	temp = 0
	g = list(map(int, input().split()))
	lst = list(map(int, input().split()))
	lst.reverse()
	for i in range(len(lst)):
		temp += lst[i] * g[1] ** i
	h.append(temp)
if h[0] > h[1]:
	print('>')
elif h[0] < h[1]:
	print('<')
else:
	print('=')


(n, a) = map(int, input().split())
s1 = input().split()
s1 = [0] * (40 - n) + s1
(m, b) = map(int, input().split())
s2 = input().split()
s2 = [0] * (40 - m) + s2
sum1 = 0
sum2 = 0
for i in range(40):
	sum1 += int(s1[i]) * a ** (40 - i - 1)
	sum2 += int(s2[i]) * b ** (40 - i - 1)
if sum1 > sum2:
	print('>')
elif sum2 == sum1:
	print('=')
else:
	print('<')


(a, abase) = map(int, input().split())
aval = list(map(int, input().split()))
first = 0
for i in range(a):
	first += aval[i] * abase ** (a - 1)
	a -= 1
(b, bbase) = map(int, input().split())
bval = list(map(int, input().split()))
second = 0
for i in range(b):
	second += bval[i] * bbase ** (b - 1)
	b -= 1
if first == second:
	print('=')
elif first < second:
	print('<')
else:
	print('>')


def solve(n, a):
	li = list(map(int, input().split()))[::-1]
	ans = 0
	for i in range(0, len(li)):
		ans += li[i] * int(pow(a, i))
	return ans
(n, a) = map(int, input().split())
ans1 = solve(n, a)
(m, b) = map(int, input().split())
ans2 = solve(m, b)
if ans1 > ans2:
	print('>')
elif ans1 < ans2:
	print('<')
else:
	print('=')


def get_num():
	(n, b) = map(int, input().split())
	ret = 0
	for x in map(int, input().split()):
		ret = ret * b + x
	return ret
a = get_num()
b = get_num()
if a == b:
	print('=')
elif a < b:
	print('<')
else:
	print('>')


(a, b) = map(int, input().split())
n1 = list(map(int, input().split()))
n = 0
for c in n1:
	n = n * b + c
(x, y) = map(int, input().split())
n2 = list(map(int, input().split()))
m = 0
for c in n2:
	m = m * y + c
if n == m:
	print('=')
elif n < m:
	print('<')
else:
	print('>')


(n, bx) = map(int, input().split())
x = list(map(int, input().split()))
(m, by) = map(int, input().split())
y = list(map(int, input().split()))
px = pow(bx, n - 1)
py = pow(by, m - 1)
px = int(px)
py = int(py)
a = 0
for i in range(n):
	a += x[i] * px
	px //= bx
b = 0
for i in range(m):
	b += y[i] * py
	py //= by
if a == b:
	print('=')
elif a > b:
	print('>')
else:
	print('<')


def main():
	X = 0
	Y = 0
	(n, bx) = [int(i) for i in input().split()]
	num = [int(i) for i in input().split()]
	for i in range(n):
		X += num[n - i - 1] * bx ** i
	(n2, by) = [int(i) for i in input().split()]
	num2 = [int(i) for i in input().split()]
	for i in range(n2):
		Y += num2[n2 - i - 1] * by ** i
	if X > Y:
		print('>')
	elif X < Y:
		print('<')
	else:
		print('=')
main()


read = lambda : map(int, input().split())
(t, bx) = read()
X = list(read())
x = sum((X[_] * bx ** (t - 1 - _) for _ in range(t)))
(t, by) = read()
Y = list(read())
y = sum((Y[_] * by ** (t - 1 - _) for _ in range(t)))
print('<' if x < y else '>' if x > y else '=')


a = []
for i in range(2):
	(n, b) = map(int, input().split())
	a.append(0)
	for x in map(int, input().split()):
		a[-1] = a[-1] * b + x
print('<>='[(a[0] == a[1]) + (a[0] >= a[1])])


def num_with_base_to_int(num_arr, base):
	num = 0
	for (i, digit) in enumerate(num_arr):
		num = num * base + int(digit)
	return num

def two_base():
	(_, baseX) = [int(x) for x in input().split(' ')]
	numX = input().split(' ')
	(_, baseY) = [int(x) for x in input().split(' ')]
	numY = input().split(' ')
	XToInt = num_with_base_to_int(numX, baseX)
	YToInt = num_with_base_to_int(numY, baseY)
	if XToInt < YToInt:
		return '<'
	elif XToInt > YToInt:
		return '>'
	elif XToInt == YToInt:
		return '='
print(two_base())


(n, base_x) = input().split(' ')
n = int(n)
base_x = int(base_x)
X = input().split(' ')
for (i, x) in enumerate(X):
	X[i] = int(x)
(n, base_y) = input().split(' ')
n = int(n)
base_y = int(base_y)
Y = input().split(' ')
for (i, y) in enumerate(Y):
	Y[i] = int(y)
x_sum = 0
pow_x = 0
for i in range(len(X) - 1, -1, -1):
	x_sum += X[i] * base_x ** pow_x
	pow_x += 1
y_sum = 0
pow_y = 0
for i in range(len(Y) - 1, -1, -1):
	y_sum += Y[i] * base_y ** pow_y
	pow_y += 1
if x_sum > y_sum:
	print('>')
elif y_sum > x_sum:
	print('<')
else:
	print('=')


(a, b) = map(int, input().split())
c = list(map(int, input().split()))
(d, e) = map(int, input().split())
f = list(map(int, input().split()))
n1 = 0
n2 = 0
for i in range(len(c)):
	n1 += c[i] * b ** (len(c) - i - 1)
for i in range(len(f)):
	n2 += f[i] * e ** (len(f) - i - 1)
if n1 > n2:
	print('>')
elif n1 == n2:
	print('=')
else:
	print('<')


(n, bx) = map(int, input().split())
x = list(map(int, input().split()))
(m, by) = map(int, input().split())
y = list(map(int, input().split()))
xx = bx ** (n - 1)
yy = by ** (m - 1)
ansx = 0
ansy = 0
for i in range(n):
	ansx += x[i] * xx
	xx //= bx
for i in range(m):
	ansy += y[i] * yy
	yy //= by
if ansx > ansy:
	print('>')
elif ansx < ansy:
	print('<')
else:
	print('=')


cin = lambda : map(int, input().split())

def solve():
	(n, a) = cin()
	sum = 0
	for i in cin():
		sum = sum * a + i
	return sum
(ans1, ans2) = (solve(), solve())
print('>' if ans1 > ans2 else '<' if ans1 < ans2 else '=')


(n, b1) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a.reverse()
(m, b2) = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
b.reverse()
summ1 = a[0]
summ2 = b[0]
base1 = b1
base2 = b2
for i in range(1, n):
	summ1 += a[i] * base1
	base1 *= b1
for i in range(1, m):
	summ2 += b[i] * base2
	base2 *= b2
if summ1 > summ2:
	print('>')
elif summ1 == summ2:
	print('=')
else:
	print('<')


import sys
l = 0
for line in sys.stdin:
	if l == 0:
		(xn, xb) = map(int, line.split())
	if l == 1:
		xi = line.split()
	if l == 2:
		(yn, yb) = map(int, line.split())
	if l == 3:
		yi = line.split()
	l += 1
x = 0
i = xn - 1
p = 0
while i >= 0:
	x += int(xi[p]) * xb ** i
	i -= 1
	p += 1
i = yn - 1
p = 0
while i >= 0:
	x -= int(yi[p]) * yb ** i
	i -= 1
	p += 1
if x > 0:
	print('>')
elif x == 0:
	print('=')
else:
	print('<')


I = input
(n, bx) = map(int, I().split())
x = list(map(int, I().split()))
(m, by) = map(int, I().split())
y = list(map(int, I().split()))
x10 = sum((x[i] * bx ** (n - i - 1) for i in range(n)))
y10 = sum((y[i] * by ** (m - i - 1) for i in range(m)))
if x10 == y10:
	print('=')
elif x10 < y10:
	print('<')
else:
	print('>')


def convert_base(s: str, base: int):
	digits = list(map(int, s.strip().split()))
	return sum((digit * base ** (len(digits) - position - 1) for (position, digit) in enumerate(digits)))
(n, bx) = map(int, input().strip().split())
x = convert_base(input(), bx)
(m, by) = map(int, input().strip().split())
y = convert_base(input(), by)
if x == y:
	print('=')
elif x < y:
	print('<')
else:
	print('>')


a = int(input().split()[1])
b = input().split()
c = int(input().split()[1])
d = input().split()
power = 0
total = 0
for i in range(len(b) - 1, -1, -1):
	total += int(b[i]) * a ** power
	power += 1
a = total
power = 0
total = 0
for i in range(len(d) - 1, -1, -1):
	total += int(d[i]) * c ** power
	power += 1
c = total
if a == c:
	print('=')
elif a > c:
	print('>')
else:
	print('<')


[n, bx] = input().split()
n = int(n)
bx = int(bx)
x = input().split()
[m, by] = input().split()
m = int(m)
by = int(by)
y = input().split()
ansx = 0
ansy = 0
dx = 1
dy = 1
for i in reversed(x):
	ansx = ansx + int(i) * dx
	dx = dx * bx
for i in reversed(y):
	ansy = ansy + int(i) * dy
	dy = dy * by
if ansx == ansy:
	print('=\n')
if ansx > ansy:
	print('>\n')
if ansx < ansy:
	print('<\n')


def calc():
	(n, b) = map(int, input().split())
	x = list(map(int, input().split()))
	a = 0
	for i in x:
		a = a * b + i
	return a
l_n = list()
for _ in range(2):
	l_n.append(calc())
if l_n[0] < l_n[1]:
	print('<')
elif l_n[1] < l_n[0]:
	print('>')
else:
	print('=')


def Two_Bases():
	x = list(map(int, input().split()))
	dx = list(map(int, input().split()))
	s = 0
	for i in dx:
		s = x[1] * s + i
	return s
X = Two_Bases()
Y = Two_Bases()
if X == Y:
	print('=')
elif X < Y:
	print('<')
elif X > Y:
	print('>')


(x, bx) = map(int, input().split())
a = list(map(int, input().split()))
(y, by) = map(int, input().split())
b = list(map(int, input().split()))
one = two = 0
power = 0
for (i, x) in enumerate(reversed(a)):
	one += x * bx ** i
for (i, x) in enumerate(reversed(b)):
	two += x * by ** i
if one < two:
	print('<')
elif one == two:
	print('=')
else:
	print('>')


(n1, base1) = list(map(int, input().strip(' ').split(' ')))
x = list(map(int, input().strip(' ').split(' ')))
(n2, base2) = list(map(int, input().strip(' ').split(' ')))
y = list(map(int, input().strip(' ').split(' ')))

def basex_base10(x, n, base):
	ans = 0
	for i in range(n):
		ans = ans + x[i] * base ** (n - i - 1)
	return ans
if basex_base10(x, n1, base1) > basex_base10(y, n2, base2):
	print('>')
elif basex_base10(x, n1, base1) < basex_base10(y, n2, base2):
	print('<')
else:
	print('=')


(n, b1) = (int(x) for x in input().split())
s = input().split()
(x1, x2) = (0, 0)
for i in range(n):
	x1 += int(s[i]) * b1 ** (n - i - 1)
(n, b2) = (int(x) for x in input().split())
s = input().split()
for i in range(n):
	x2 += int(s[i]) * b2 ** (n - i - 1)
if x1 == x2:
	print('=')
elif x1 < x2:
	print('<')
else:
	print('>')


(n, bx) = map(int, input().split())
X = list(map(int, input().split()))
d_x = 0
for (idx, x) in enumerate(X[::-1]):
	d_x += x * bx ** idx
(m, by) = map(int, input().split())
Y = list(map(int, input().split()))
d_y = 0
for (idx, y) in enumerate(Y[::-1]):
	d_y += y * by ** idx
if d_x < d_y:
	print('<')
elif d_x > d_y:
	print('>')
else:
	print('=')


import sys
(n, bx) = map(int, input().split())
b = list(reversed(list(map(int, input().split()))))
num = 0
base = 1
for i in range(n):
	num += b[i] * base
	base *= bx
(m, by) = map(int, input().split())
ba = list(reversed(list(map(int, input().split()))))
num2 = 0
base = 1
for i in range(m):
	num2 += ba[i] * base
	base *= by
if num > num2:
	print('>')
elif num < num2:
	print('<')
else:
	print('=')


import random
import sys

def _(f):
	for l in f:
		for i in l.split():
			yield int(i)
g = _(sys.stdin)
(n, b) = (next(g), next(g))
X = 0
for i in range(n):
	X = X * b + next(g)
Y = 0
(n, b) = (next(g), next(g))
for i in range(n):
	Y = Y * b + next(g)
if X < Y:
	print('<')
elif X > Y:
	print('>')
else:
	print('=')


(nx, bx) = map(int, input().split())
x = input().split()
for i in range(len(x)):
	x[i] = int(x[i])
(ny, by) = map(int, input().split())
y = input().split()
for i in range(len(y)):
	y[i] = int(y[i])
x10 = 0
for i in range(nx):
	x10 += x[nx - i - 1] * bx ** i
y10 = 0
for i in range(ny):
	y10 += y[ny - i - 1] * by ** i
if x10 < y10:
	print('<')
elif x10 > y10:
	print('>')
else:
	print('=')


(a, b) = (0, 0)
(n, m) = [int(x) for x in input().split()]
for item in input().split():
	a = a * m + int(item)
(n, m) = [int(x) for x in input().split()]
for item in input().split():
	b = b * m + int(item)
if a < b:
	print('<')
elif a > b:
	print('>')
else:
	print('=')


(n, b1) = map(int, input().split())
a = list(map(int, input().split()))
(m, b2) = map(int, input().split())
b = list(map(int, input().split()))
num1 = 0
num2 = 0
for i in range(n):
	num1 += a[i] * b1 ** (n - i - 1)
for i in range(m):
	num2 += b[i] * b2 ** (m - i - 1)
if num1 == num2:
	print('=')
elif num1 > num2:
	print('>')
else:
	print('<')


def anyToDecimal(num, n):
	baseStr = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '10': 10, '11': 11, '12': 12, '13': 13, '14': 14, '15': 15, '16': 16, '17': 17, '18': 18, '19': 19, '20': 20, '21': 21, '22': 22, '23': 23, '24': 24, '25': 25, '26': 26, '27': 27, '28': 28, '29': 29, '30': 30, '31': 31, '32': 32, '33': 33, '34': 34, '35': 35, '36': 36, '37': 37, '38': 38, '39': 39, '40': 40}
	new_num = 0
	nNum = len(num) - 1
	for i in num:
		new_num = new_num + baseStr[i] * pow(n, nNum)
		nNum = nNum - 1
	return new_num
n1 = list(map(int, input().split()))
x = list(map(str, input().split()))
n2 = list(map(int, input().split()))
y = list(map(str, input().split()))
ans_x = anyToDecimal(x, n1[1])
ans_y = anyToDecimal(y, n2[1])
if ans_x > ans_y:
	print('>')
elif ans_x < ans_y:
	print('<')
else:
	print('=')


import logging
import copy
import sys
import math
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)

def solve(b, nums):
	nums.reverse()
	sum = 0
	for (i, num) in enumerate(nums):
		sum += math.pow(b, i) * num
	return sum

def main():
	base10 = [0, 0]
	for i in range(2):
		line = list(map(int, input().split()))
		(n, b) = (line[0], line[1])
		nums = list(map(int, input().split()))
		base10[i] = solve(b, nums)
	if base10[0] == base10[1]:
		print('=')
	elif base10[0] < base10[1]:
		print('<')
	elif base10[0] > base10[1]:
		print('>')

def log(*message):
	logging.debug(message)
main()


(n, base) = [int(i) for i in input().split()]
nl = input().split()
numa = 0
for c in nl:
	numa *= base
	numa += int(c)
(n, base) = [int(i) for i in input().split()]
nl = input().split()
numb = 0
for c in nl:
	numb *= base
	numb += int(c)
if numa == numb:
	print('=')
elif numa > numb:
	print('>')
else:
	print('<')


a = int(input().split()[1])
(*b,) = map(int, input().split())
c = 0
for i in b:
	c = c * a + i
d = int(input().split()[1])
(*e,) = map(int, input().split())
f = 0
for i in e:
	f = f * d + i
if c == f:
	print('=')
elif c < f:
	print('<')
else:
	print('>')


(n, bx) = map(int, input().split())
summa1 = 0
s = list(map(int, input().split()))
for i in range(n):
	a = s[i]
	summa1 += bx ** (n - i - 1) * a
(m, by) = map(int, input().split())
summa2 = 0
s = list(map(int, input().split()))
for i in range(m):
	a = s[i]
	summa2 += by ** (m - i - 1) * a
if summa1 > summa2:
	print('>')
elif summa2 == summa1:
	print('=')
else:
	print('<')


x = 0
y = 0
n = 0
(a, b) = map(int, input().split())
nums1 = [int(n) for n in input().split()]
(c, d) = map(int, input().split())
nums2 = [int(n) for n in input().split()]
for i in range(a - 1, -1, -1):
	coeff = nums1[i]
	x = x + coeff * b ** (a - i - 1)
for i in range(c - 1, -1, -1):
	coeff = nums2[i]
	y = y + coeff * d ** (c - i - 1)
if x < y:
	print('<')
elif x > y:
	print('>')
elif x == y:
	print('=')
else:
	print('error')


n1 = 0
(n, b) = list(map(int, input().split()))
a = list(map(int, input().split()))
a.reverse()
for i in range(n):
	n1 += a[i] * b ** i
n2 = 0
(n, b) = list(map(int, input().split()))
a = list(map(int, input().split()))
a.reverse()
for i in range(n):
	n2 += a[i] * b ** i
if n1 < n2:
	print('<')
if n1 == n2:
	print('=')
if n1 > n2:
	print('>')


cin = lambda : list(map(int, input().split()))
(n, b) = cin()
num = cin()
(x1, x2) = (0, 0)
for i in range(1, len(num) + 1):
	x1 += b ** (i - 1) * num[-i]
(n, b) = cin()
num = cin()
for i in range(1, len(num) + 1):
	x2 += b ** (i - 1) * num[-i]
if x1 > x2:
	print('>')
elif x1 == x2:
	print('=')
else:
	print('<')


(xcount, xschis) = map(int, input().split())
x = list(map(int, input().split()))
x = x[::-1]
sumx = 0
(ycount, yschis) = map(int, input().split())
y = list(map(int, input().split()))
y = y[::-1]
sumy = 0
s = ''
for i in range(len(x)):
	sumx += pow(xschis, i) * x[i]
for j in range(len(y)):
	sumy += pow(yschis, j) * y[j]
if sumx > sumy:
	s = '>'
elif sumx == sumy:
	s = '='
else:
	s = '<'
print(s)


(n, b) = map(int, input().split())
X = 0
for x in list(map(int, input().split())):
	n -= 1
	X += x * b ** n
(m, a) = map(int, input().split())
Y = 0
for y in list(map(int, input().split())):
	m -= 1
	Y += y * a ** m
if X < Y:
	print('<')
elif X > Y:
	print('>')
else:
	print('=')


def getNum(x, base):
	ans = 0
	for r in x:
		ans = ans * base + r
	return ans
(N, bx) = map(int, input().strip().split())
x = [int(x) for x in input().strip().split()]
(M, by) = map(int, input().strip().split())
y = [int(x) for x in input().strip().split()]
xx = getNum(x, bx)
yy = getNum(y, by)
if xx == yy:
	print('=')
elif xx < yy:
	print('<')
else:
	print('>')


(n, xbase) = list(map(int, input().split()))
xs = list(map(int, input().split()))
(m, ybase) = list(map(int, input().split()))
ys = list(map(int, input().split()))
x = 0
xt = 1
for c in xs[::-1]:
	x += c * xt
	xt *= xbase
y = 0
yt = 1
for c in ys[::-1]:
	y += c * yt
	yt *= ybase
if x < y:
	print('<')
elif x > y:
	print('>')
else:
	print('=')


import math
(n, b1) = map(int, input().split())
l1 = list(map(int, input().split()))
x = 0
y = 0
(m, b2) = map(int, input().split())
l2 = list(map(int, input().split()))
for i in range(0, n):
	x = x + l1[i] * math.pow(b1, n - i - 1)
for i in range(0, m):
	y = y + l2[i] * math.pow(b2, m - i - 1)
if x == y:
	print('=')
elif x < y:
	print('<')
else:
	print('>')


(nx, bx) = map(int, input().split())
x = list(map(int, input().split()))
(ny, by) = map(int, input().split())
y = list(map(int, input().split()))

def todec(x, b):
	res = 0
	exp = len(x) - 1
	for i in x:
		res += i * b ** exp
		exp -= 1
	return res
x = todec(x, bx)
y = todec(y, by)
if x > y:
	print('>')
elif x < y:
	print('<')
else:
	print('=')


import sys
input_file = sys.stdin
(_, base_x) = map(int, input_file.readline().rstrip().split())
number_x = list(reversed(list(map(int, input_file.readline().rstrip().split()))))
(_, base_y) = map(int, input_file.readline().rstrip().split())
number_y = list(reversed(list(map(int, input_file.readline().rstrip().split()))))
val_x = 0
for (i, val) in enumerate(number_x):
	val_x += number_x[i] * base_x ** i
val_y = 0
for (i, val) in enumerate(number_y):
	val_y += number_y[i] * base_y ** i
if val_x < val_y:
	print('<')
elif val_y < val_x:
	print('>')
else:
	print('=')


read = lambda : map(int, input().split())
f = lambda p, a, n: sum((a[i] * p ** (n - i - 1) for i in range(n)))
(n, x) = read()
X = f(x, list(read()), n)
(m, y) = read()
Y = f(y, list(read()), m)
print('<' if X < Y else '>' if X > Y else '=')


def to_int(digits, base):
	r = 0
	for d in digits:
		r = r * base + d
	return r
(n, bx) = map(int, input().split())
x = to_int(list(map(int, input().split())), bx)
(m, by) = map(int, input().split())
y = to_int(list(map(int, input().split())), by)
if x == y:
	print('=')
elif x < y:
	print('<')
else:
	print('>')


(n, bx) = map(int, input().split())
s = input().split()
s = [int(x) for x in s]
add1 = 0
for i in range(n):
	add1 += pow(bx, i) * s[-i - 1]
(m, by) = map(int, input().split())
t = input().split()
t = [int(x) for x in t]
add2 = 0
for i in range(m):
	add2 += pow(by, i) * t[-i - 1]
if add1 == add2:
	print('=')
elif add1 > add2:
	print('>')
else:
	print('<')


b = [int(i) for i in input().split(' ')]
X = sum((int(j) * b[1] ** i for (i, j) in zip(range(b[0]), input().split(' ')[::-1])))
b = [int(i) for i in input().split(' ')]
Y = sum((int(j) * b[1] ** i for (i, j) in zip(range(b[0]), input().split(' ')[::-1])))
if X > Y:
	print('>')
if X < Y:
	print('<')
if X == Y:
	print('=')


I = lambda : [*map(int, input().split())]
(n, a) = I()
x = 0
for c in I():
	x = x * a + c
(m, b) = I()
y = 0
for c in I():
	y = y * b + c
print('<=>'[(x >= y) + (x > y)])


import sys
(a, b) = [int(x) for x in input().split()]
base = b ** (a - 1)
res1 = 0
arr = [int(x) for x in input().split()]
for digit in arr:
	res1 += digit * base
	base //= b
(a, b) = [int(x) for x in input().split()]
base = b ** (a - 1)
res2 = 0
arr = [int(x) for x in input().split()]
for digit in arr:
	res2 += digit * base
	base //= b
if res1 > res2:
	print('>')
elif res1 < res2:
	print('<')
else:
	print('=')


def readnum():
	(n, b) = (int(w) for w in input().split())
	x = 0
	nums = list((int(w) for w in input().split()))
	return sum((nums[i] * b ** (n - 1 - i) for i in range(n)))
x = readnum()
y = readnum()
if x == y:
	print('=')
if x < y:
	print('<')
if x > y:
	print('>')


(n, bx) = map(int, input().split(' '))
vx = list(map(int, input().split(' ')))
res = 0
for i in range(n):
	res = res * bx + vx[i]
(n, bx) = map(int, input().split(' '))
vx = list(map(int, input().split(' ')))
ret = 0
for i in range(n):
	ret = ret * bx + vx[i]
if res == ret:
	print('=')
else:
	print('>' if res > ret else '<')


import sys

class Scanner:

	def __init__(self):
		self.current_tokens = []

	def remaining_tokens(self):
		return len(self.current_tokens)

	def nextline(self):
		assert self.remaining_tokens() == 0, 'Reading next line with remaining tokens'
		return input()

	def nexttokens(self):
		return self.nextline().split()

	def nexttoken(self):
		if len(self.current_tokens) == 0:
			self.current_tokens = self.nexttokens()
		assert self.remaining_tokens() > 0, 'Not enough tokens to parse.'
		return self.current_tokens.pop(0)

	def nextints(self, n=-1):
		if n == -1:
			return list(map(int, self.nexttokens()))
		else:
			return [self.nextint() for i in range(n)]

	def nextint(self):
		return int(self.nexttoken())

def quit():
	sys.exit(0)
stdin = Scanner()
nextint = stdin.nextint
nextints = stdin.nextints
nextline = stdin.nextline
(N, BX) = nextints()
X = 0
for p in range(N):
	X *= BX
	X += nextint()
(N, BY) = nextints()
Y = 0
for p in range(N):
	Y *= BY
	Y += nextint()
if X < Y:
	print('<')
elif X > Y:
	print('>')
else:
	print('=')


(nx, x) = [int(i) for i in input().split()]
X = 0
for i in input().split():
	X += int(i) * x ** (nx - 1)
	nx -= 1
(ny, y) = [int(i) for i in input().split()]
Y = 0
for i in input().split():
	Y += int(i) * y ** (ny - 1)
	ny -= 1
if X < Y:
	print('<')
elif X > Y:
	print('>')
else:
	print('=')


def intConvert(l):
	for i in range(0, len(l)):
		l[i] = int(l[i])

def base10(l, base):
	result = 0
	for i in range(0, len(l)):
		result += l[len(l) - i - 1] * base ** i
	return result
d1 = input().split()
digits1 = input().split()
intConvert(d1)
intConvert(digits1)
result1 = base10(digits1, d1[1])
d2 = input().split()
digits2 = input().split()
intConvert(d2)
intConvert(digits2)
result2 = base10(digits2, d2[1])
if result1 == result2:
	print('=')
elif result1 < result2:
	print('<')
elif result1 > result2:
	print('>')


(n, base) = map(int, input().split())
a = [int(i) for i in input().split()]
chislo1 = 0
for i in range(n):
	chislo1 += a[i] * base ** (n - i - 1)
(n, base) = map(int, input().split())
a = [int(i) for i in input().split()]
chislo2 = 0
for i in range(n):
	chislo2 += a[i] * base ** (n - i - 1)
if chislo2 > chislo1:
	print('<')
elif chislo2 == chislo1:
	print('=')
else:
	print('>')


(n, b) = map(int, input().split())
x = list(map(int, input().split()))
x.reverse()
a = 0
for i in range(n):
	a += x[i] * pow(b, i)
(n, b) = map(int, input().split())
x = list(map(int, input().split()))
x.reverse()
c = 0
for i in range(n):
	c += x[i] * pow(b, i)
if a == c:
	print('=')
elif a < c:
	print('<')
else:
	print('>')


q = input().split()
n1 = int(q[0])
b1 = int(q[1])
a = input().split()
n1 = 0
for i in range(len(a)):
	a[i] = int(a[i])
	n1 = n1 * b1 + a[i]
q = input().split()
n2 = int(q[0])
b2 = int(q[1])
b = input().split()
n2 = 0
for i in range(len(b)):
	b[i] = int(b[i])
	n2 = n2 * b2 + b[i]
if n1 < n2:
	print('<')
elif n1 > n2:
	print('>')
else:
	print('=')


(nx, bx) = map(int, input().split(' ')[:2])
xs = list(map(int, input().split(' ')[:nx]))
(ny, by) = map(int, input().split(' ')[:2])
ys = list(map(int, input().split(' ')[:ny]))
p = 1
x = 0
for d in reversed(xs):
	x += d * p
	p *= bx
p = 1
y = 0
for d in reversed(ys):
	y += d * p
	p *= by
if x == y:
	print('=')
elif x < y:
	print('<')
else:
	print('>')


(x, n) = map(int, input().split())
a = 0
for e in map(int, input().split()):
	a += e
	a *= n
a //= n
(x, n) = map(int, input().split())
b = 0
for e in map(int, input().split()):
	b += e
	b *= n
b //= n
if a < b:
	print('<')
elif a > b:
	print('>')
else:
	print('=')


l = [int(x) for x in input().split()]
(n, bx) = (l[0], l[1])
a = [int(x) for x in input().split()]
xx = 0
for y in a:
	xx *= bx
	xx += y
l = [int(x) for x in input().split()]
(m, by) = (l[0], l[1])
b = [int(x) for x in input().split()]
yy = 0
for y in b:
	yy *= by
	yy += y
if xx < yy:
	print('<')
elif xx == yy:
	print('=')
else:
	print('>')


(n, bx) = list(map(int, input().split()))
x = list(map(int, input().split()))
(m, by) = list(map(int, input().split()))
y = list(map(int, input().split()))
X = sum((x[i] * bx ** (n - i - 1) for i in range(n)))
Y = sum((y[i] * by ** (m - i - 1) for i in range(m)))
print('<' if X < Y else '>' if X > Y else '=')


import math
(a, b) = map(int, input().split())
ls = []
ls = map(int, input().split())
ls = list(ls)
number = 0
B = 1
for x in reversed(ls):
	number += x * B
	B = B * b
(p, q) = map(int, input().split())
lst = []
lst = map(int, input().split())
lst = list(lst)
numberY = 0
B = 1
for x in reversed(lst):
	numberY += x * B
	B = B * q
if number > numberY:
	print('>')
if number < numberY:
	print('<')
if number == numberY:
	print('=')


(nx, bx) = map(int, input().split())
x = list(map(int, input().split()))
m = 0
for i in range(nx):
	m += bx ** (nx - i - 1) * x[i]
(ny, by) = map(int, input().split())
y = list(map(int, input().split()))
n = 0
for i in range(ny):
	n += by ** (ny - i - 1) * y[i]
if m == n:
	print('=')
elif m > n:
	print('>')
else:
	print('<')


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
(m, k1) = map(int, input().split())
b = list(map(int, input().split()))
a = a[::-1]
b = b[::-1]
s1 = 0
for i in range(n):
	s1 += pow(k, i) * a[i]
s2 = 0
for i in range(m):
	s2 += pow(k1, i) * b[i]
if s1 > s2:
	print('>')
elif s1 < s2:
	print('<')
else:
	print('=')


first_number_base = [int(info) for info in input().split(' ')]
first_number_digits = input().split(' ')
second_number_base = [int(info) for info in input().split(' ')]
second_number_digits = input().split(' ')
if first_number_base[1] != 10:
	first_number = 0
	counter = 0
	for i in list(reversed(first_number_digits)):
		first_number += int(i) * first_number_base[1] ** counter
		counter += 1
else:
	first_number = int(''.join(first_number_digits))
if second_number_base[1] != 10:
	second_number = 0
	counter = 0
	for i in list(reversed(second_number_digits)):
		second_number += int(i) * second_number_base[1] ** counter
		counter += 1
else:
	second_number = int(''.join(second_number_digits))
if first_number < second_number:
	print('<')
elif first_number > second_number:
	print('>')
else:
	print('=')


(n, bx) = map(int, input().split())
X = list(map(int, input().split()))
(m, by) = map(int, input().split())
Y = list(map(int, input().split()))

def to_10(X, n, bx):
	ten_base_n = 0
	for i in range(len(X)):
		ten_base_n += X[len(X) - i - 1] * bx ** i
	return ten_base_n
if to_10(X, n, bx) == to_10(Y, m, by):
	print('=')
elif to_10(X, n, bx) > to_10(Y, m, by):
	print('>')
else:
	print('<')


import os
import sys
while True:
	l = ''
	for line in sys.stdin:
		l = line
		break
	if l != '':
		(n, bx) = map(int, l.split())
		x = 0
		lx = input().split()
		for i in range(0, n):
			x = x * bx + int(lx[i])
		(m, by) = map(int, input().split())
		y = 0
		ly = input().split()
		for i in range(0, m):
			y = y * by + int(ly[i])
		if x > y:
			print('>')
		elif x < y:
			print('<')
		else:
			print('=')
	else:
		break


(n, b) = [int(i) for i in input().split(' ')]
bx = [int(i) for i in input().split(' ')]
(m, a) = [int(i) for i in input().split(' ')]
ax = [int(i) for i in input().split(' ')]
(bb, aa) = (0, 0)
for i in bx:
	aa = aa * b + i
for i in ax:
	bb = bb * a + i
if aa < bb:
	print('<')
elif aa == bb:
	print('=')
else:
	print('>')


def parser():
	a = input().split()
	base = int(a[1])
	exponent = 0
	out = 0
	vct = input().split()
	for i in reversed(vct):
		out += pow(base, exponent) * int(i)
		exponent += 1
	return out
a = parser()
b = parser()
if a == b:
	print('=')
elif a > b:
	print('>')
else:
	print('<')


def to_int(b, arr):
	d = 1
	r = 0
	for x in arr:
		r += d * x
		d *= b
	return r
(n, bx) = map(int, input().split())
xd = [int(i) for i in input().split()][::-1]
(n, by) = map(int, input().split())
yd = [int(i) for i in input().split()][::-1]
x = to_int(bx, xd)
y = to_int(by, yd)
if x < y:
	print('<')
elif x == y:
	print('=')
else:
	print('>')


(n1, r1) = map(int, input().split())
v1 = 0
x1 = 1
for d in list(map(int, input().split()))[::-1]:
	v1 += d * x1
	x1 *= r1
r2 = int(input().split()[1])
v2 = 0
x2 = 1
for d in list(map(int, input().split()))[::-1]:
	v2 += d * x2
	x2 *= r2
print('>' if v1 > v2 else '<' if v1 < v2 else '=')


(X, x) = map(int, input().split())
a = [int(i) for i in input().split()]
a = a[::-1]
h = 0
for i in range(X):
	h += a[i] * x ** i
(Y, y) = map(int, input().split())
b = [int(i) for i in input().split()]
b = b[::-1]
k = 0
for i in range(Y):
	k += b[i] * y ** i
if h == k:
	print('=')
elif h < k:
	print('<')
else:
	print('>')


(n, bx) = [int(var) for var in input().split()]
x = [int(var) for var in input().split()]
(m, by) = [int(var) for var in input().split()]
y = [int(var) for var in input().split()]

def findnum(b, db):
	num = 0
	for dig in db:
		num *= b
		num += dig
	return num
ax = findnum(bx, x)
ay = findnum(by, y)
if ax < ay:
	print('<')
elif ax == ay:
	print('=')
else:
	print('>')


def get():
	(N, B) = map(int, input().split())
	res = 0
	for i in input().split():
		res = B * res + int(i)
	return res
x = get()
y = get()
if x < y:
	print('<')
elif x > y:
	print('>')
else:
	print('=')


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
first = int(0)
second = int(0)
now = int(1)
for i in range(len(l) - 1, -1, -1):
	first = first + now * l[i]
	now = now * m
(n1, m1) = map(int, input().split())
l1 = list(map(int, input().split()))
now = 1
for i in range(len(l1) - 1, -1, -1):
	second = second + now * l1[i]
	now = now * m1
if second == first:
	print('=')
elif second > first:
	print('<')
else:
	print('>')


(n, bx) = list(map(int, input().split()))
num = list(map(int, input().split()))
num.reverse()
orig = 0
for i in range(0, len(num)):
	orig += num[i] * bx ** i
(n, bx2) = list(map(int, input().split()))
num = list(map(int, input().split()))
num.reverse()
orig2 = 0
for i in range(0, len(num)):
	orig2 += num[i] * bx2 ** i
if orig == orig2:
	print('=')
elif orig < orig2:
	print('<')
else:
	print('>')


(n, bx) = map(int, input().split())
xarr = list(map(int, input().split()))
x = 0
for i in range(n):
	x += xarr[n - i - 1] * bx ** i
(n, bx) = map(int, input().split())
yarr = list(map(int, input().split()))
y = 0
for i in range(n):
	y += yarr[n - i - 1] * bx ** i
print('=' if x == y else '<' if x < y else '>')


(n, bx) = map(int, input().split())
s1 = 0
p1 = 1
for i in list(map(int, input().split()))[::-1]:
	s1 += i * p1
	p1 *= bx
(m, by) = map(int, input().split())
s2 = 0
p2 = 1
for i in list(map(int, input().split()))[::-1]:
	s2 += i * p2
	p2 *= by
if s1 == s2:
	print('=')
elif s1 > s2:
	print('>')
else:
	print('<')


(n, m) = map(int, input().split())
f = list(map(int, input().split()))
f.reverse()
x = 0
x1 = 1
y = 0
y1 = 1
for i in range(n):
	x += x1 * f[i]
	x1 *= m
(n, m) = map(int, input().split())
f = list(map(int, input().split()))
f.reverse()
for i in range(n):
	y += y1 * f[i]
	y1 *= m
if x < y:
	print('<')
elif x == y:
	print('=')
else:
	print('>')


x = 0
y = 0
(n, m) = input().split()
n = int(n)
m = int(m)
for z in input().split():
	x = x * m + int(z)
(n, m) = input().split()
n = int(n)
m = int(m)
for z in input().split():
	y = y * m + int(z)
if x == y:
	print('=')
elif x > y:
	print('>')
else:
	print('<')


res = [0, 0]
for i in range(2):
	(n, b) = map(int, input().split())
	for x in [int(x) for x in input().split()]:
		res[i] *= b
		res[i] += x
print('<' if res[0] < res[1] else '>' if res[0] > res[1] else '=')


(x_n, x_osn) = map(int, input().split())
x_data = list(map(int, input().split()))
x_10 = 0
for i in range(x_n):
	x_10 += x_data[i] * x_osn ** (x_n - i - 1)
(y_n, y_osn) = map(int, input().split())
y_data = list(map(int, input().split()))
y_10 = 0
for i in range(y_n):
	y_10 += y_data[i] * y_osn ** (y_n - i - 1)
if x_10 < y_10:
	print('<')
elif x_10 > y_10:
	print('>')
else:
	print('=')


(n, bx) = map(int, input().split())
x = list(map(int, input().split()))[::-1]
(m, by) = map(int, input().split())
y = list(map(int, input().split()))[::-1]
d1 = 0
deg = 1
for d in x:
	d1 += d * deg
	deg *= bx
d2 = 0
deg = 1
for d in y:
	d2 += d * deg
	deg *= by
print('>' if d1 > d2 else '<' if d1 < d2 else '=')


(n, bx) = map(int, input().split())
x = 0
xdigits = [int(x) for x in input().split()]
for i in reversed(range(n)):
	x += xdigits[n - i - 1] * bx ** i
(m, by) = map(int, input().split())
y = 0
ydigits = [int(y) for y in input().split()]
for i in reversed(range(m)):
	y += ydigits[m - i - 1] * by ** i
if x > y:
	print('>')
elif x < y:
	print('<')
else:
	print('=')