In this HackerRank A Chessboard Game problem solution we have Given the initial coordinates of the players' coins, assuming optimal play, determine which player will win the game.

HackerRank A Chessboard Game problem solution


Problem solution in Python.

t = int(input())
for _ in range(t):
    x , y = map(int,input().split())
    if x%4==0 or x%4 ==3 or y%4==0 or y%4==3:
        print("First")
    else:
        print("Second")


Problem solution in Java.

import java.io.*;
import java.util.*;

public class Solution {

  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int n = in.nextInt();
    for(int i = 0; i < n; i++) {
      int playerX = in.nextInt();
      int playerY = in.nextInt();
      System.out.println(findWinner(playerX, playerY));
    }
  }

  public static String findWinner(int x, int y) {
    return (x-1)%4<2 && (y-1)%4<2? "Second" : "First";
  }
}


Problem solution in C++.

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;


int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */
    int t, z, x, y;
    cin >> t;
    for (z=0; z<t; z++)
    {
        cin >> x >> y;
        x %= 4;
        y %= 4;
        if (x==0 || x==3 || y==0 || y==3) cout << "First\n";
        else                              cout << "Second\n";
    }
    return 0;
}


Problem solution in C.

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main() {
    int t, m, n;
    scanf("%d", &t);
    while(t--) {
        scanf("%d %d", &m, &n);
        int i = m % 4;
        int j = n % 4;
        if ((i == 1 || i == 2) && (j == 1 || j == 2)) {
            printf("Second\n");
        } else {
            printf("First\n");
        }
    }
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */    
    return 0;
}