Form biggest Number

i am unable to run the test cases. my code is run fine in eclipse

please share the code.
thanks

public class FormBiggestNumber {

	static void printLargest(ArrayList<String> arr){ 
	
		Collections.sort(arr, new Comparator<String>(){ 

		
		@Override
		public int compare(String X, String Y) { 
		
		
			String XY=X + Y; 
		
		
			String YX=Y + X; 
		
				return XY.compareTo(YX) > 0 ? -1:1; 
	} 
	}); 
		
	Iterator<String> it = arr.iterator(); 

	while(it.hasNext()) 
		System.out.print(it.next()); 
	
	} 
	
	
	public static void main (String[] args) { 
		
		
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		
		while(t--!=0) {
			int n=sc.nextInt();
			ArrayList<String> arr; 
			arr = new ArrayList<>(n);
		for(int i=0;i<n;i++) {
			String N=sc.nextLine();
			arr.add(N);
			}
		printLargest(arr); 
		}
		
		
	
	} 
}