#K60972. Determine the Color of a Traffic Light

    ID: 31205 Type: Default 1000ms 256MiB

Determine the Color of a Traffic Light

Determine the Color of a Traffic Light

You are given a traffic light that cycles through three colors: green, yellow, and red. The green light lasts for G seconds, yellow lasts for Y seconds, and red lasts for R seconds.

At time \( T \) seconds after all lights have turned green, your task is to determine which color the light is showing.

The cycle period of the traffic light is given by: \[ T_{cycle} = G + Y + R \] and the elapsed time within the current cycle is: \[ t = T \bmod T_{cycle} \]

  • If \( t < G \), the light is green.
  • If \( G \leq t < G+Y \), the light is yellow.
  • If \( t \geq G+Y \), the light is red.

Write a program that reads from standard input and determines the color of the traffic light for each query.

inputFormat

The input is read from standard input (stdin) and has the following format:

Q
G1 Y1 R1 T1
G2 Y2 R2 T2
... 
GQ YQ RQ TQ

where Q is the number of queries, and for each query, four integers are provided representing the durations of the green, yellow, and red lights, and the time \( T \) respectively.

outputFormat

For each query, print the color of the traffic light ("green", "yellow", or "red") on a separate line to standard output (stdout).

## sample
1
5 3 2 7
yellow

</p>