Compare Continued Fractions
시간 제한2초메모리 제한1024 MB
길이가 최대 100,000인 두 유한 연분수가 주어질 때, 두 연분수가 나타내는 유리수의 대소를 비교해 <, =, > 중 하나를 출력한다.
문제
In this problem, you have to compare two rational numbers represented by their continued fractions.
A finite continued fraction is a sequence . The following restrictions are applied:
- is a non-negative finite integer,
- the elements , , , , are integers,
- for each ,
- if .
These restrictions allow to establish a one-to-one correspondence between rational numbers and finite continued fractions: every rational number corresponds to the unique continued fraction such that Thus, the following notation is used: . For example, so we write .
Given the continued fractions for two rational numbers and , find whether , , or .
입력
The input consists of two lines. The first line contains the continued fraction for the rational number . The second line contains the continued fraction for the rational number .
Each continued fraction is given as a sequence of integers separated by single spaces. First goes an integer , the length of the continued fraction (). It is followed by integers which are the elements of the continued fraction: , , , , (). It is guaranteed that for each and if .
출력
On the first line of output, print a single character: "<" if , "=" if , or ">" if .