|시간 제한||메모리 제한||제출||정답||맞힌 사람||정답 비율|
|1 초||128 MB||0||0||0||0.000%|
Have you ever thought about comparing the weight of fruits? That’s what you should do in this problem! Given a series of fruit weight comparisons, you should anticipate the result of another comparison. In this problem, all fruits of the same kind are identical and have the same weights. Each fruit weight comparison is something like “a X ≤ b Y” in which a and b are positive integers, and X and Y are fruit names. Such a comparison means that the weight of a fruits of type X is less than or equal to the weight of b fruits of type Y.
The input contains multiple test cases. Each test case starts with a line containing n, which is the number of given comparisons. Each of the next n lines gives a comparison in the form of “a X b Y” meaning that “a X ≤ b Y”. The last line of each test case contains the comparison query in the same form of “a X b Y” inquiring the comparison of “a X” and “b Y”.
A case of n = 0 shows the end of input and should not be processed. All integers in the input (except the last n which is 0) are positive and are not greater than 100. Fruit names are case-sensitive strings of (lowercase and uppercase) letters with length no more than 50.
For each test case, write one line with your result for that test case. Your result can be one of the followings (assume the comparison query was “a X b Y”):
2 2 Orange 3 Apple 1 Apple 1 Peach 2 Orange 3 Peach 1 2 Orange 3 Apple 2 Orange 2 Apple 2 3 a 2 A 2 A 3 a 5 A 5 a 2 3 B 2 A 2 A 3 B 2 A 3 B 3 2 b 2 A 2 A 2 C 3 C 2 b 1 A 1 b 0
<= UNAVAILABLE >= == INCONSISTENT