M×N 체스판 위 K개의 (p,q)-나이트가 위 또는 왼쪽으로만 움직이는 정상 게임에서 두 플레이어가 최적으로 둘 때 승자를 판정한다. 각 나이트가 독립적인 부분 게임이므로 그런디 수를 구해야 한다.
어려움8게임 이론동적 계획법수학구현아직 제출이 없습니다시간 제한1초메모리 제한512 MBConsider a chessboard of the size M×N. There are K fairy chess pieces called (p,q)-knights (p<q) placed in some squares on this board. A (p,q)-knight's move is similar to a regular chess knight's move, with some constraints though.
When (p,q)-knight moves, it can move p squares horizontally and q squares vertically (only upward), or q squares horizontally (only to the left) and p squares vertically. In other words, if we number the M rows of the board from top to bottom, and the N columns from left to right, the direction in which the knight moves q squares must be where the corresponding coordinate decreases. Moving outside the board is prohibited. However, multiple knights are allowed to occupy the same square.
Two players are playing the game, alternating moves. Each player in his turn chooses some knight and moves it according to the rules. The player who is not able to move any knight loses the game.
Given a board configuration, determine the winner assumng that both players play optimally.
The first line contains five integers: M, N, K, p, q (1≤M,N≤109, 1≤K≤105, 1≤p<q≤20). Each of the following K lines contains coordinates r_i and c_i of a corresponding knight (1≤r_i≤M, 1≤c_i≤N).
Print one line with one word: First if the first player wins the game if both players play optimally, and Second otherwise.