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, <image> 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.
8 18
1 1 4 15 7 4 9 3
8 17
1 10 2 10 3 11 14 10
 4 7
3 0 6 6
3 11
7 10 10
 2 24
20 9
10 23
21 10 15 11 6 8 20 16 14 11
 10 40
39 39 39 39 39 39 39 39 39 39
10 39
38 38 38 38 38 38 38 38 38 38
 9 7
2 0 3 2 6 6 1 4 3
9 6
4 4 1 1 4 5 5 0 2
 9 39
10 20 16 36 30 29 28 9 8
9 38
12 36 10 22 6 3 19 12 34
 5 2
1 0 0 0 1
6 8
1 4 7 2 0 0
 2 6
5 5
2 34
1 0
 7 5
4 0 4 1 3 0 4
4 35
1 18 7 34
 2 35
1 0
2 6
5 5
 10 23
5 21 4 15 12 7 10 7 16 21
4 17
3 11 1 14
 5 37
9 9 9 9 9
6 27
13 0 0 0 0 0
 7 22
1 13 9 16 7 13 3
4 4
3 0 2 1
 1 36
35
4 5
2 4 4 1
 2 2
1 0
1 3
1
 3 5
1 0 0
3 3
2 2 2
 10 40
1 1 14 5 6 3 3 11 3 25
10 39
1 11 24 33 25 34 38 29 27 33
 6 7
1 1 2 1 2 1
6 6
2 3 2 2 2 2
 5 37
29 29 5 7 27
3 39
13 1 10
 6 4
1 1 1 2 2 2
7 3
1 2 2 0 1 0 0
 8 8
4 0 4 3 4 1 5 6
8 24
19 8 15 6 10 7 2 18
 6 29
1 1 1 1 1 1
10 21
1 1 1 1 1 1 1 1 1 1
 10 29
15 22 0 5 11 12 17 22 4 27
4 22
9 2 8 14
 7 39
28 16 13 25 19 23 4
7 38
33 8 2 19 3 21 14
 2 19
4 8
8 18
7 8 6 8 4 11 9 1
 2 40
22 38
5 39
8 9 32 4 1
 8 36
23 5 27 1 10 7 26 27
10 35
28 33 9 22 10 28 26 4 27 29
 10 40
18 1 2 25 28 2 10 2 17 37
10 39
37 8 12 8 21 11 23 11 25 21
 8 21
5 19 0 14 13 13 10 5
10 13
1 0 0 6 11 10 8 2 8 1
 2 4
3 3
2 15
1 0
 10 6
3 5 4 2 4 2 3 5 4 2
10 7
3 2 1 1 3 1 0 3 4 5
 1 22
15
10 14
3 3 3 3 3 3 3 3 3 3
 10 29
10 19 8 27 1 24 13 15 13 26
2 28
20 14
 5 5
4 4 4 4 4
4 6
5 5 5 5
 2 29
11 11
6 26
11 11 11 11 11 11
 10 3
1 0 0 0 0 0 0 0 0 0
8 13
1 0 0 0 0 0 0 0
 10 16
15 15 4 0 0 0 0 7 10 9
10 9
4 8 0 3 1 5 4 8 1 0
 9 37
1 35 7 33 20 21 26 24 5
10 40
39 4 11 9 33 12 26 32 11 8
 10 40
39 39 39 39 39 39 39 39 39 39
10 8
7 7 7 7 7 7 7 7 7 7
 6 26
7 6 4 18 6 1
6 25
5 3 11 1 8 15
 2 8
1 0
4 2
1 0 0 0
 4 22
18 16 1 2
10 26
23 0 12 24 16 2 24 25 1 11
 7 28
1 10 7 0 13 14 11
6 38
8 11 27 5 14 35
 3 3
1 0 2
2 5
2 4
 2 24
4 18
2 40
29 24
 3 39
27 4 3
8 38
32 15 11 34 35 27 30 15
 3 2
1 1 1
1 3
1
 9 3
1 0 0 1 1 0 0 1 2
6 4
1 2 0 1 3 2
 9 40
39 39 39 39 39 39 39 39 39
6 35
34 34 34 34 34 34
 7 26
8 0 0 0 0 0 0
9 9
3 3 3 3 3 3 3 3 3
 1 8
5
9 27
23 23 23 23 23 23 23 23 23
 7 31
14 6 16 6 26 18 17
7 24
22 10 4 5 14 6 9
 2 37
25 2
3 26
13 13 12
 1 40
1
2 5
1 0
 10 36
1 13 13 23 31 35 5 32 18 21
9 38
32 1 20 14 12 37 13 15 23
 10 38
16 19 37 32 16 7 14 33 16 11
10 39
10 27 35 15 31 15 17 16 38 35
 9 9
2 2 3 6 3 6 3 8 4
6 10
4 7 7 0 3 8
 9 34
5 8 4 4 26 1 30 5 24
10 27
1 6 3 10 8 13 22 3 12 8
 5 3
1 0 0 0 0
4 27
1 0 0 0
 6 19
4 9 14 1 3 1
8 10
1 1 1 7 3 7 3 0
 5 35
22 18 28 29 11
2 3
2 0
 1 30
1
1 31
1
 10 39
34 2 24 34 11 6 33 12 22 21
10 36
25 35 17 24 30 0 1 32 14 35
 2 7
1 0
2 3
2 2
 4 5
1 4 2 0
4 4
3 2 2 3
 3 5
2 2 3
3 6
4 3 5
 7 34
21 22 28 16 30 4 27
7 26
5 13 21 10 8 12 10
 1 3
1
1 2
1
 6 37
22 15 14 10 1 8
6 36
18 5 28 10 1 17
 3 11
6 5 2
8 10
5 0 1 8 3 5 1 4
 10 22
3 3 3 3 3 3 3 3 3 3
3 40
19 19 19
 10 39
35 12 31 35 28 27 25 8 22 25
10 40
23 21 18 12 15 29 38 32 4 8
 8 26
6 6 17 25 24 8 8 25
4 27
24 7 5 24
 10 16
15 15 4 0 0 0 0 7 10 9
7 9
4 8 0 3 1 5 0
 9 35
34 3 20 29 27 30 2 8 5
7 33
17 3 22 31 1 11 6
 2 8
4 1
1 7
1
 1 24
6
3 9
1 1 1
 2 10
6 0
10 26
16 14 8 18 24 4 9 5 22 25
 3 5
1 1 3
10 4
3 3 2 3 0 0 0 3 1 1
 7 15
8 5 8 10 13 6 13
8 13
1 6 9 10 12 3 12 8
 6 11
10 6 1 0 2 2
9 10
4 3 4 1 1 6 3 4 1
 7 2
1 0 0 0 1 0 1
9 6
1 1 5 1 2 5 3 5 3
 6 4
3 3 2 2 0 2
6 5
1 1 1 1 0 3
 2 9
5 5
4 3
1 0 0 0
 6 5
4 4 4 3 1 3
7 6
4 2 2 2 5 0 4
 4 4
1 3 1 3
9 3
1 1 0 1 2 2 2 2 1
 1 30
9
7 37
20 11 18 14 0 36 27
 2 12
1 4
8 16
4 4 10 6 15 10 8 15
 2 34
1 32
2 33
2 0
 4 20
1 1 1 1
5 22
1 1 1 1 1
 5 38
1 31 2 21 21
9 37
8 36 32 30 13 9 24 2 35
 7 29
14 26 14 22 11 11 8
6 28
2 12 10 17 0 14
 4 39
13 25 23 35
6 38
19 36 20 4 12 33
 2 8
1 0
2 3
2 2
 6 16
4 9 13 4 2 8
4 10
3 5 2 4
 1 2
1
1 40
1
 10 31
6 27 17 22 14 16 25 9 13 26
10 39
6 1 3 26 12 32 28 19 9 19
 2 40
2 0
5 13
4 0 0 0 0
 1 7
2
4 8
3 2 3 2
 5 38
2 24 34 14 17
8 34
4 24 31 2 14 15 8 15
 8 28
3 1 10 19 10 14 21 15
8 21
14 0 18 13 2 1 18 6
 1 10
7
3 9
2 1 7
 10 2
1 1 1 1 1 1 1 1 1 1
10 34
14 14 14 14 14 14 14 14 14 14
 10 21
4 7 7 2 13 7 19 19 18 19
3 31
6 11 28
 10 2
1 0 1 0 1 0 1 0 1 0
10 3
2 2 2 2 2 2 2 2 2 2
 7 3
1 1 2 1 2 0 2
2 2
1 0
 3 9
2 5 4
1 19
15
 2 5
3 3
5 2
1 0 0 1 0
 3 19
9 18 16
4 10
4 3 5 4
 2 5
3 3
6 6
4 2 0 1 1 0
 1 9
2
1 10
2
 7 16
15 15 4 0 0 7 10
7 9
4 8 0 3 1 5 0
 10 39
20 12 10 32 24 14 37 35 10 38
9 40
1 13 0 10 22 20 1 5 35
 9 37
2 6 1 9 19 6 11 28 35
9 40
1 6 14 37 1 8 31 4 9
 6 16
2 13 7 13 15 6
10 22
17 17 21 9 16 11 4 4 13 17
 2 2
1 0
2 3
1 0
 2 2
1 0
1 3
2

= > < > > = < > = = > < > < > < = = > = < < > = < < < < = = < < > > < < > < > > = < = < < < > > > > < > < < = > > = < = > = > < = < > = > < > > > > > > < < < = < < > > < < < < = < < > < = > = < < < < > < < > < > > = < < = > > = < < =
"""
Codeforces Round 333 (Div. 2)

Problem 602 A.

@author yamaton
@date 2015-11-24
"""

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 p(*args, **kwargs):
#     return print(*args, file=sys.stderr, **kwargs)


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)


if __name__ == '__main__':
    main()
