{"raw_statement":[{"iden":"statement","content":"Tamer is traveling with his brother on a long highway. He sees a traffic light at a distance. He calculated that it will take him x seconds until he arrives at the traffic light, he also knows that the green light lasts for g seconds, the yellow light lasts for y seconds and the red light lasts for r seconds. Now he is wondering in what color will the light be when he arrives there?\n\nYou know he is now busy driving, so he asks you to tell him the answer! you know that the light has just turned green at the moment of his question, and that the sequence of the lights is: _GREEN_, _YELLOW_, _RED_ and then _GREEN_ and so on.\n\nThe first line of input contains one integer T - the number of test cases.\n\nEach test case contains four integers x, g, y, r as described in the statement.\n\n1 ≤ x, g, y, r ≤ 109\n\nFor each test case output a single word, _\"RED\"_ or _\"YELLOW\"_ or _\"GREEN\"_ without the quotes.\n\nIn the samples the light changes as follows:\n\nLight: _g, g, g, g, g, y, y, r, r, r, r, r , r , r , r , g , g , g , g ..._\n\nTime : _0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18..._\n\n"},{"iden":"input","content":"The first line of input contains one integer T - the number of test cases.Each test case contains four integers x, g, y, r as described in the statement.1 ≤ x, g, y, r ≤ 109"},{"iden":"output","content":"For each test case output a single word, _\"RED\"_ or _\"YELLOW\"_ or _\"GREEN\"_ without the quotes."},{"iden":"examples","content":"Input35 5 2 87 5 2 816 5 2 8OutputYELLOWREDGREEN"},{"iden":"note","content":"In the samples the light changes as follows:Light: _g, g, g, g, g, y, y, r, r, r, r, r , r , r , r , g , g , g , g ..._Time : _0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18..._"}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ T \\in \\mathbb{Z} $ be the number of test cases.  \nFor each test case $ k \\in \\{1, \\dots, T\\} $, let:  \n- $ x_k \\in \\mathbb{Z}^+ $: time (in seconds) until Tamer arrives at the traffic light.  \n- $ g_k, y_k, r_k \\in \\mathbb{Z}^+ $: durations (in seconds) of green, yellow, and red phases respectively.  \n\nThe light cycle is periodic with period $ C_k = g_k + y_k + r_k $, and the sequence within one cycle is:  \n- Green for $ [0, g_k) $,  \n- Yellow for $ [g_k, g_k + y_k) $,  \n- Red for $ [g_k + y_k, g_k + y_k + r_k) $.  \n\n**Constraints**  \n1. $ 1 \\le T \\le 10^5 $  \n2. $ 1 \\le x_k, g_k, y_k, r_k \\le 10^9 $ for all $ k \\in \\{1, \\dots, T\\} $  \n\n**Objective**  \nFor each test case $ k $, determine the color of the light at time $ x_k $:  \nLet $ t_k = x_k \\bmod C_k $.  \n- If $ 0 \\le t_k < g_k $, output \"GREEN\"  \n- If $ g_k \\le t_k < g_k + y_k $, output \"YELLOW\"  \n- If $ g_k + y_k \\le t_k < C_k $, output \"RED\"","simple_statement":"Tamer is driving and will reach a traffic light in x seconds. The light cycle is: GREEN for g seconds, then YELLOW for y seconds, then RED for r seconds, then repeats. The light just turned green. What color will it be when he arrives?","has_page_source":false}