P23632 [AtCoder] Stone Picking Game
省选
题目描述

Problem Description

There is a pile with $ N $ stones, and two players take turns picking stones from this pile. The player who picks the last stone wins the game. The number of stones that can be picked is determined as follows:

The first player (first turn) can pick any number of stones between $ 1 $ and $ P $. For subsequent turns, each player can pick any number of stones between $ 1 $ and the number of stones picked in the previous turn plus $ 1 $.

For example, if the first player picks $ 3 $ stones, the second player can pick between $ 1 $ and $ 4 $ stones. If the second player picks $ 2 $ stones, the first player can then pick between $ 1 $ and $ 3 $ stones.

Given $ N $ and $ P $, there is a guaranteed winning strategy for either the first or the second player. Write a program to determine which player has a guaranteed winning strategy.

Input Format

The input is given from the standard input in the following format:

$ N $ $ P $

  • The first line contains an integer $ N $ ($1 \leq N \leq 500$), which represents the number of stones in the pile at the start of the game.
  • The second line contains an integer $ P $ ($1 \leq P \leq N$), which represents the maximum number of stones the first player can pick on the first turn.

Output Format

Output first if the first player has a guaranteed winning strategy, or second if the second player has a guaranteed winning strategy. End the output with a newline.

Sample Input and Output

Sample Input #1

4
2

Sample Output #1

first

Sample Input #2

5
2

Sample Output #2

second

Sample Input #3

100
100

Sample Output #3

first

Sample Input #4

100
19

Sample Output #4

second

Notes/Hints

Sample Explanation 1

The first player picks $ 1 $ stone. The second player can then pick either $ 1 $ or $ 2 $ stones, but in either case, the first player can pick the remaining stones and win. Therefore, the first player has a guaranteed winning strategy.

Sample Explanation 2

If the first player picks $ 2 $ stones, the second player will pick the remaining $ 3 $ stones and win. If the first player picks $ 1 $ stone, the second player can pick $ 1 $ stone, leaving $ 3 $ stones. From this state, no matter what the first player does next, the second player can pick the remaining stones and win. Therefore, the second player has a guaranteed winning strategy.

Sample Explanation 3

The first player can pick all the stones in the first turn.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
4 2
样例输出
first