P16298 [Lanqiao Cup 2026 NOI Qualifier Python C Group] Problem Solving Speed Duel

Description

Under the incandescent lights in the computer lab, the sound of typing rises and falls. Xiaolan and Xiaohong agree to have a duel on problem-solving speed. There are a total of $n$ problems in the contest. They start at the same time, and whoever finishes all problems first wins. Although the problems are the same, their solving rhythms are very different: - Xiaolan: Solving each problem always takes $t_1$ minutes. But he has a special habit: after finishing the $i$-th problem, he needs to rest for $i \times d_1$ minutes to calm down before starting the next problem. - Xiaohong: Solving each problem always takes $t_2$ minutes. Similarly, after finishing the $i$-th problem, she needs to rest for $i \times d_2$ minutes. You are the judge of this duel. Given the total number of problems and the time parameters of both players, please determine the final winner. If Xiaolan wins, output `BLUE`. If Xiaohong wins, output `RED`. If they finish at the same time, it is a draw; output `DRAW`.

Input Format

The first line contains an integer $T$, indicating that there are $T$ groups of testdata. The next $T$ lines each contain five integers $n, t_1, d_1, t_2, d_2$, with meanings as described above.

Output Format

For each group of testdata, output one line with the result: - If Xiaolan finishes first, output `BLUE`. - If Xiaohong finishes first, output `RED`. - If they finish at the same time, output `DRAW`.

Explanation/Hint

### Constraints For $30\%$ of the test cases, $1 \le T \le 100$, $1 \le n, t_1, d_1, t_2, d_2 \le 10^3$. For all test cases, $1 \le T \le 10^3$, $1 \le n, t_1, d_1, t_2, d_2 \le 10^5$. Translated by ChatGPT 5