human
Give me a Python program to compare those two numbers given the following:
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 bx and a number Y represented in base by. Compare those two numbers.

Input

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

The second line contains n space-separated integers x1, x2, ..., xn (0 ≤ xi < bx) — 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 by (1 ≤ m ≤ 10, 2 ≤ by ≤ 40, bx ≠ by), where m is the number of digits in the by-based representation of Y, and the fourth line contains m space-separated integers y1, y2, ..., ym (0 ≤ yi < by) — 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

&lt;

Input

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

Output

&gt;

Note

In the first sample, X = 1011112 = 4710 = Y.

In the second sample, X = 1023 = 215 and Y = 245 = 1123, thus X < Y.

In the third sample,  and Y = 48031509. We may notice that X starts with much larger digits and bx is much larger than by, so X is clearly larger than Y.
Using python3 can you solve the prior task?
assistant
#Here is Python program to compare those two numbers.

#!/usr/bin/env python3
# 602A_mem.py - Codeforces.com/problemset/problem/602/A by Sergey 2015

import unittest
import sys

###############################################################################
# Mem Class (Main Program)
###############################################################################

class Mem:
    """ Mem representation """

    def __init__(self, test_inputs=None):
        """ Default constructor """

        it = iter(test_inputs.split("\n")) if test_inputs else None

        def uinput():
            return next(it) if it else sys.stdin.readline().rstrip()

        # Reading single elements
        [self.n, self.bx] = map(int, uinput().split())

        # Reading a single line of multiple elements
        self.numsx = list(map(int, uinput().split()))

        # Reading single elements
        [self.m, self.by] = map(int, uinput().split())

        # Reading a single line of multiple elements
        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):
        """ Main calcualtion function of the class """

        if self.x == self.y:
            return "="
        if self.x > self.y:
            return ">"
        return "<"

###############################################################################
# Unit Tests
###############################################################################

class unitTests(unittest.TestCase):

    def test_single_test(self):
        """ Mem class testing """

        # Constructor test
        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)

        # Sample test
        self.assertEqual(Mem(test).calculate(), "=")

        # Sample test
        test = "3 3\n1 0 2\n2 5\n2 4"
        self.assertEqual(Mem(test).calculate(), "<")

        # Sample test
        test =...