#T674. 地外遗迹
地外遗迹
Description
Your friend Jones is an interstellar adventurer, and as you know, interstellar adventurers always encounter strange situations. Today, Jones sent you a message asking for help. Jones discovered an ancient relic on a planet not far from Earth, and the gate of the relic has a peculiar mechanism. After some exploration and drawing on his adventure experience, Jones concluded the following: each time, two words appear on the screen of the mechanism. If the first word is lexicographically smaller than the second word, you need to press the green button; otherwise, press the red button. There is an additional issue to note. Due to the relic's age, the dictionary order of the language used by the relic's creators differs somewhat from ours. Of course, the well-traveled Jones is familiar with these differences and will provide you with the correct dictionary order. Can you write a program to help him unlock the gate's mechanism? PS: Words consist only of lowercase letters. For example: "uvwxyzabcdefghijklmnopqrst" indicates that in the relic's language, 'u' has the smallest dictionary order, while 't' has the largest. According to their dictionary order, 'u' comes before 'a'.
Input Format
The first line contains a string of 26 lowercase letters (the dictionary order provided by Jones, where letters appearing earlier have a smaller dictionary order, and there are no duplicate lowercase letters). The second line contains a number n, indicating that n comparisons will follow (1 <= n <= 100000). The subsequent n lines each contain two words separated by a space.
Output Format
For each pair of input words, if the first word is lexicographically smaller than the second word according to the relic's dictionary order, output "green"; otherwise, output "red".
【Data Range】
For 20% of the data, 2 <= n <= 20;
For 60% of the data, 2 <= n <= 5000;
For 100% of the data, 2 <= n <= 100000, word length <= 30, character range is 'a'~'z';
【Sample Explanation】
According to the lexicographical order in the first line "uvwxyzabcdefghijklmnopqrst":
For the first pair of words, the first letter 'a' < 'b', so the word "apple" is lexicographically smaller than "banana", output "green".
For the second pair of words, the first letter 'b' == 'b', the second letter 'a' < 'l', so "banana" is lexicographically smaller than "blueberry", output "green".
For the third pair of words, the first letter 'a' > 'w', so "banana" is lexicographically larger than "watermelon", output "red".
For the fourth pair of words, the first letter 'v' < 'b', so "vegetable" is lexicographically smaller than "banana", output "green".
For the fifth pair of words, the first letter 'a' == 'a', the second letter 'p' == 'p', the first word "apple" has a third character while the second word "ap" does not, so "apple" is lexicographically larger than "ap", output "red".
CodesOnlineSource