We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

- Prepare
- Algorithms
- Game Theory
- Stone Division

# Stone Division

# Stone Division

Consider the following game:

- There are two players,
*First*and*Second*, sitting in front of a pile of stones.*First*always plays first. - There is a set, , of distinct integers defined as .
- The players move in alternating turns. During each turn, a player chooses some and splits one of the piles into exactly smaller piles of equal size. If no exists that will split one of the available piles into exactly equal smaller piles, the player loses.
- Both players always play optimally.

Given , , and the contents of , find and print the winner of the game. If *First* wins, print `First`

; otherwise, print `Second`

.

**Input Format**

The first line contains two space-separated integers describing the respective values of (the size of the initial pile) and (the size of the set).

The second line contains distinct space-separated integers describing the respective values of .

**Constraints**

**Output Format**

Print `First`

if the *First* player wins the game; otherwise, print `Second`

.

**Sample Input 0**

```
15 3
5 2 3
```

**Sample Output 0**

```
Second
```

**Explanation 0**

The initial pile has stones, and . During *First*'s initial turn, they have two options:

- Split the initial pile into equal piles, which forces them to lose after the following sequence of turns:

- Split the initial pile into equal piles, which forces them to lose after the following sequence of turns:

Because *First* never has any possible move that puts them on the path to winning, we print `Second`

as our answer.