Help me in solving PR0BLEM problem

My issue

Output is correct for various test cases upon submitting The Answer is Getting Wrong

My code

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

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

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner s=new Scanner(System.in);
		int t=s.nextInt();
		for(int i=0;i<t;i++){
		    int n=s.nextInt(),m=s.nextInt();
		    if (m==n){
		        System.out.println("YES");
		        break;}
		    else {
		    for(int j=1;j<=n;j++){
		        if(n-j==m+j){
		            System.out.println("Yes");
                    break;}		        
		    }
		    
		    for (int k=1;k<=m;k++){
		        if(m-k==n+3*k){
		            System.out.println("YES");
		            break;}
		        else{
		            System.out.println("NO");
		            break;}
		  }
		  }
		    }}}
	


Problem Link: PR0BLEM Problem - CodeChef

@pavanausipuram
plzz refer the following solution for better understanding of the logic and implementation.

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

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

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
	    Scanner read = new Scanner(System.in);
	    int t = read.nextInt();
	    for(int i=0; i<t; i++){
	        int n = read.nextInt();
	        int m = read.nextInt();
	        int x = Math.abs(n-m);
	        if(x%2==0 || x%4==0){
	            System.out.println("YES");
	        }
	        else{
	            System.out.println("NO");
	        }
	    }
	}
}