TLE '16 Contest 3 P4 - Gaussian Elimination

View as PDF

Submit solution


Points: 7 (partial)
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type
Gaussian (left) and Abelian (right) enjoy a relaxing game of Gaussian Elimination.

Gaussian Elimination is a 2-player game played on a rectangular grid with N rows and M columns.

Initially, every cell in this grid is full. The two players take turns performing either a row reduction or a column reduction. In a row reduction, a player empties all of the cells in an entire row. Likewise, in a column reduction, a player empties all of the cells in a column. A player must empty at least one full cell during his/her turn. The winner is the person who empties the last cell.

The two players, Abelian and Gaussian, are playing a game of Gaussian Elimination. Abelian does not want to lose to Gaussian, who plays perfectly (and is the creator of the game). This means that Gaussian will always try to play in an optimal way to try to guarantee a victory, if it is possible. Please help Abelian determine whether he should go first or second!

Constraints

Subtask 1 [20%]

1 \le N, M \le 3

Subtask 2 [60%]

1 \le N, M \le 50

Subtask 3 [20%]

1 \le N, M \le 10^9

Input Specification

The first line contains N.

The second line contains M.

Output Specification

The output should either be First or Second, representing whether Abelian should make the first or second move.

Sample Input 1

3
1

Sample Output 1

First

Explanation for Sample Output 1

This game of Gaussian Elimination has 3 rows and 1 column. Abelian should go first and perform a column reduction. This empties all of the cells, and Abelian wins the game.

Sample Input 2

2
2

Sample Output 2

Second

Comments

There are no comments at the moment.