Help me in solving SWMA problem

My issue

my code is ready but one of any hidden test case is not solved and i am not able to analyse the hidden test case

My code

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

class Codechef
{
    public static void main (String[] args)
	{
	    Scanner sc=new Scanner(System.in);
	    int t=sc.nextInt();
	for(int i=0;i<t;i++)
	{
	    int A=sc.nextInt();
	    int B=sc.nextInt();
	    int c,d;
	    int g=0;
	    int s=0;
	    if(A<B)
	    {
	        while(A>0)
	        {
	        c=A%10;
	         A=A/10;
	        g=g*10+c;
	         }
	         while(B>0)
	         {
	              d=B%10;
	             B=B/10;
	              s=s*10+d;
	         }
	    }
	    else
	    {
	        System.out.println("yes");
	    }
	         if(g>s)
	         {
	             System.out.println("yes");
	         }
	         else{
	               System.out.println("no");
	         }
	    
	}
}
}


Problem Link: Swapping Marks Digits Practice Coding Problem - CodeChef

You are maximizing B too.

Say this example:
14 18

You maximize both, getting:
41 81

Then you print “no”

But that’s wrong because you can do this:
41 18

You have to maximize A and minimize B