#T471. 地外遗迹

地外遗迹

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 ruin on a planet not far from Earth, and the door of the ruin 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 ruin's age, the dictionary order of the language used by the ruin's inhabitants differs somewhat from ours. Of course, the well-traveled Jones is aware of these differences and will tell you the correct dictionary order. Can you write a program to help him unlock the ruin's door? PS: Words consist only of lowercase letters. For example: "uvwxyzabcdefghijklmnopqrst" indicates that in the ruin's language, 'u' is the smallest in dictionary order, while 't' is the largest. According to their dictionary order, 'u' comes before 'a'.

Input Format

The first line contains a string of 26 lowercase letters (this is the dictionary order Jones tells you; the earlier a letter appears, the smaller its 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 next 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 ruin's dictionary order, output "green"; otherwise, output "red".

```input1 uvwxyzabcdefghijklmnopqrst 5 apple banana banana blueberry apple watermelon vegetable banana apple ap ``` ```output1 green green red green red ``` ## Hint

【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".


Source

CodesOnline