P10506 Magic Beads
Description
Freda and rainbow are students of the School of Magic at Preternatural Kingdom University (PKU). To show the magic they have just learned, they decide to play a game.
At the beginning, there are $n$ piles of magic beads in front of Freda, and the $i$-th pile has $a_i$ beads. Freda and rainbow take turns to perform the following operation:
1. Choose any pile among the $n$ piles whose number of beads is greater than $1$. Let the number of beads in this pile be $p$. The proper divisors of $p$ that are less than $p$ are $b_1, b_2 \cdots b_m$, for a total of $m$ divisors.
2. Use magic to turn this pile into $m$ piles, with $b_1, b_2 \cdots b_m$ beads in each pile respectively.
3. Choose one pile among these $m$ piles and use magic to make it disappear.
Note that after one operation, the number of piles increases by $m - 2$, and the total number of beads across all piles may change.
When it is a player's turn, if every pile has exactly $1$ bead, then that player loses.
Both Freda and rainbow play with the best strategy, and Freda goes first. Predict who will win.
Input Format
This problem has only one test point and contains multiple test cases, ending at EOF.
For each test case, the first line contains an integer $n$.
The second line contains $n$ integers $a_i$.
Output Format
For each test case, assuming both players play optimally, if Freda can win, output `freda`; if Rainbow can win, output `rainbow`.
Explanation/Hint
Constraints: for all testdata, $1 \le n \le 100$, $1 \le a_i \le 1000$.
Translated by ChatGPT 5