Problem p03197 - Generation 1

Orig Description

Score : 500 points
Problem StatementThere is an apple tree that bears apples of N colors. The N colors of these apples are numbered 1 to N, and there are a_i apples of Color i.
You and Lunlun the dachshund alternately perform the following operation (starting from you):
Choose one or more apples from the tree and eat them. Here, the apples chosen at the same time must all have different colors.
The one who eats the last apple from the tree will be declared winner. If both you and Lunlun play optimally, which will win?
Constraints
1 \leq N \leq 10^5
1 \leq a_i \leq 10^9
All values in input are integers.
InputInput is given from Standard Input in the following format:
N
a_1
a_2
:
a_N
OutputIf you will win, print first; if Lunlun will win, print second.
Sample Input 12
1
2
Sample Output 1first
Let Color 1 be red, and Color 2 be blue. In this case, the tree bears one red apple and two blue apples.
You should eat the red apple in your first turn. Lunlun is then forced to eat one of the blue apples, and you can win by eating the other in your next turn.
Note that you are also allowed to eat two apples in your first turn, one red and one blue (not a winning move, though).
Sample Input 23
100000
30000
20000
Sample Output 2second

Extracted Specification

An integer N (1 ≤ N ≤ 10^5), representing some quantity or size.
A list of integers A of size N, where each integer is between 1 and 1e9.

### Example Input:

```
2
1
2
```

### Function Signature:
Write a function f(N, A) that takes in the input. 
def f(N: int, A: List[int]): 
    ''' 
    N: an integer 
    A: a list of integers 
    '''

Test Case Generator

Sure! Let's write a test case generator for the given problem statement about the apple tree. We'll write a function `tcgen` that will generate random test cases within the given constraints.

Here is the generator function:

```python
import random

def tcgen():
    # Generate a random N within the range 1 to 10^5
    N = random.randint(1, 10**5)
    
    # Generate a list of N integers, each ranging from 1 to 10^9
    A = [random.randint(1, 10**9) for _ in range(N)]
    
    return N, A

# Example of generating a test case
N, A = tcgen()
print(N)
for a in A:
    print(a)
```

### Explanation:
1. `N = random.randint(1, 10**5)`: This generates a random integer `N` which is the number of colors, within the given constraint \(1 \leq N \leq 10^5\).
2. `A = [random.randint(1, 10**9) for _ in range(N)]`: This generates a list `A` of size `N`, where each element is a random integer representing the number of apples of a particular color, within the given constraint \(1 \leq a_i \leq 10^9\).

### Example Usage:
Running the `tcgen` function will generate a random test case. For instance, if the function is run, it might produce the following output:
```
5
987654321
123456789
654321
987654
12345
```

This corresponds to an input where:
- `N` is 5.
- The number of apples for each color are: 987654321, 123456789, 654321, 987654, and 12345 respectively.

You can use this generator to create multiple test cases to validate your solution to the problem.

Extract Arguments

def extract_arguments(fh):
    N = int(fh.readline().strip())
    A = []
    for _ in range(N):
        A.append(int(fh.readline().strip()))
    return N, A

# if __name__ == "__main__":
#     input_path = sys.argv[1]
#     with open(input_path, 'r') as fh: 
#     N, A = extract_arguments(fh)
#     f(N, A)