Help me in solving MAKEDIV3 problem

My issue

the same which is written in python is working even testcase3 fails like expected output is 123 but it giving 105. but it is not working with java

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 int finding(int a)
    {
        for(int i=(int)Math.pow(10,a-1);i<(int)Math.pow(10,a)-1;i++)
        {
            if(i%3==0 && i%9!=0 && i%2!=0)
            {
                return i;
            }
        }
        return 0;
    }
	public static void main (String[] args) throws java.lang.Exception
	{
	    Scanner input=new Scanner(System.in);
	
	    int n=input.nextInt();
	    for(int i=0;i<n;i++)
	    {
	        System.out.println(finding(input.nextInt()));
	    }
		// your code goes here
	}
}

Problem Link: CodeChef: Practical coding for everyone

the logic is quite simple print n-1 times 9 then print 1 time 3 thats it