Help me in solving MONSTER1 problem

My issue

My code

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;

class Codechef
public static void main (String[] args) {
    Scanner read= new Scanner(;
     int T = read.newInt();
		int H =read.newInt();
		int X =read.newInt();
		int Y= read.newInt();
		for (int i=1;i<=T;i++){
		     else if {

Problem Link: CodeChef: Practical coding for everyone

The following link might help.

Logic I used to solve the problem