package codeJam;
import java.util.Scanner;
public class RankAndFile {

	static Scanner sc=new Scanner(System.in);
	public static void main(String[] runOnce){
		int testCases=Integer.parseInt(sc.nextLine());
		for(int caseNo=0;caseNo<testCases;caseNo++) runOnce(caseNo+1);
	}
	public static void runOnce(int caseNo){
		int N;
		boolean[] height=new boolean[2501];
		int[] remainingPeople,arrangedPeople;
		
		int currentRead,ram1,ram2,z;
		
		
		N=Integer.parseInt(sc.nextLine());
		for(int y=0;y<((2*N)-1);y++){
			for(int x=0;x<N;x++){
				currentRead=sc.nextInt();
				/*
				if(height[currentRead]) System.out.println("removing "+currentRead);
				else System.out.println("adding "+currentRead);*/
				height[currentRead]=!height[currentRead];	
			}
			sc.nextLine();
		}
		remainingPeople=new int[N];
		int y=0;
		for(int x=0;x<2501;x++){
			if(height[x]){
				remainingPeople[y]=x;
				y++;
			}
		}
		ram1=Integer.MAX_VALUE;
		
		for(int x=0;x<N;x++) if(remainingPeople[x]<ram1) ram1=remainingPeople[x];
		arrangedPeople=new int[N];
		arrangedPeople[0]=ram1;
		
		for(y=1;y<N;y++){
			ram2=Integer.MAX_VALUE;
			for(int x=0;x<N;x++){
				z=remainingPeople[x];
				if(z<ram2&&z>ram1){
					ram2=z;
				}
			}
			arrangedPeople[y]=ram1=ram2;
		}
		System.out.print("Case #"+caseNo+": ");
		for(y=0;y<N;y++){
			System.out.print(arrangedPeople[y]);
			if(y!=N-1) System.out.print(" ");
		}
		System.out.println("");
	}
}

@@ -1,8 +1,647 @@
+/*%0D%0A%0D%0ACopyright Hackers' Club, University Of Peradeniya%0D%0AAuthor : Gihan Chanaka Jayatilaka (E/4/158)%0D%0ALicensed under the Apache License, Version 2.0 (the %22License%22);%0D%0Ayou may not use this file except in compliance with the License.%0D%0AYou may obtain a copy of the License at *%0D%0Ahttp://www.apache.org/licenses/LICENSE-2.0 *%0D%0AUnless required by applicable law or agreed to in writing, software%0D%0Adistributed under the License is distributed on an %22AS IS%22 BASIS,%0D%0AWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0D%0ASee the License for the specific language governing permissions and%0D%0Alimitations under the License.%0D%0A*/%0D%0A%0D%0A
 package 

Update RankAndFile.java