luogu#P4860. Roy&October之取石子II

Roy&October之取石子II

Background

Roy and October are playing another stone-taking game. (For Season 1, see P4018.)

Problem Description

The rules are as follows: there are nn stones in total. Each turn, a player can only take pkp^k stones, where pp is a prime number, k=0k = 0 or 11, and pkp^k is less than or equal to the number of stones currently remaining. Whoever takes the last stone wins.

Now October moves first. Determine whether she has a winning strategy.

If she has a winning strategy, output one line October wins!; otherwise output one line Roy wins!.

Input Format

The first line contains a positive integer TT, the number of test cases.

Lines 22 to T+1T+1 each contain a positive integer nn, the number of stones.

Output Format

Output TT lines. Each line should be October wins! or Roy wins!.

3
5
7
14
October wins!
October wins!
October wins!

Hint

For 30%30\% of the testdata, 1n301 \le n \le 30.

For 60%60\% of the testdata, 1n1061 \le n \le 10^6.

For 100%100\% of the testdata, 1n5×1071 \le n \le 5 \times 10^7, 1T1051 \le T \le 10^5.

Extra: Since the problem setter was too lazy to generate testdata, they directly reused the input from P4018, ovo.

Translated by ChatGPT 5