Given 4 integers X, Y, A, and B. X and Y denotes the rows and the columns of a matrix such that (X, Y ≥ 2). Verify if each the gamers can meet on the identical cell of the matrix in an precisely odd variety of operations by following the given situations:
 Participant 1 is on the prime left nook of the matrix initially.
 Participant 2 is on the backside proper of the matrix initially.
 In a single operation, Participant 1 could make precisely A steps, or Participant 2 could make precisely B steps. In a single step a participant can transfer solely left, proper, up, or down cell from the present cell.
Examples:
Enter: X = 2, Y = 2, A = 2, B = 1
Output: YES
Rationalization: Operations are as follows:
 Operation 1: Participant 1 could make precisely 2 steps and initially on the prime left nook(1, 1). The sequence of two steps is as: (1, 1) > (1, 2) > (2, 2). Participant 2 is initially current on the backside proper nook(N.M) = (2, 2). It may be verified that each gamers are current at (2, 2) now. The variety of operations is 1, Which is precisely odd. Due to this fact, the output is YES.
Enter: X = 2, Y = 2, A = 1, B = 2
Output: YES
Rationalization: Operations are as follows:
 Operation 1: Participant 1 strikes to the suitable cell from the present place, Formally (1, 1) > (1, 2).
 Operation 2: Participant 2, First strikes to the left cell from the present place(2, 2) after which proper aspect to at least one step, (2, 2) > (2, 1) > (2, 2). Formally, returns to its preliminary place.
 Operation 3: Participant 1 is at at the moment (1, 2), Makes one step downwards from (1, 2) to (2, 2). It may be verified that now each the participant are at (2, 2) in 3 operations, Which is odd. Due to this fact, the output is YES.
Enter: X = 2, Y = 2, A = 1, B = 1
Output: NO
Rationalization: It may be verified that it isn’t attainable to satisfy on the identical cell in an precisely odd variety of operations. Therefore the output is NO.
Method: Implement the thought under to unravel the issue:
The issue is commentary primarily based and might be solved through the use of Mathematical ideas.
Steps had been taken to unravel the issue:
 Increment X by Y – 2 + A, Formally X+=Y2+A.
 Increment A by B, Formally A += B.
 If (X % 2 == 1 && A % 2 == 0) then output YES else NO.
Under is the code to implement the above strategy:
Java

Time Complexity: O(1)
Auxiliary House: O(1)