Comparison of Continued Fractions#5966

Comparison of Continued Fractions

1 second
64 megabytes
Hard

A finite continued (or simple) fraction of length is expressed as:

Here, a_0 is an integer, and a_i (1 \leq i \leq n) are natural numbers.

Your task is to compare the values of two given finite continued fractions.

Input

The first line of input provides the length of the first continued fraction , followed by integers a_0, \ldots, a_{m-1}, which define the first continued fraction. The second line similarly describes the second continued fraction with integers [b_0, b_1, \ldots, b_{n-1}]. Constraints are as follows: 1 \leq m, n \leq 10^5, -10^9 \leq a_0, b_0 \leq 10^9, and 1 \leq a_i, b_i \leq 10^9 for i > 0.

Output

Output a single line with less if the first fraction's value is less than the second's, great if the first fraction's value is greater, or equal if both values are the same.

Examples

Example 1

Loading
Loading