import java.util.Arrays; import java.util.Scanner; class Brother { int cm; int kg; String name; public Brother(int cm, int kg ,String name) { this.cm = cm; this.kg = kg; this.name = name; } } class paiza { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Brother[] brother = new Brother[3]; boolean check = false; Brother tmp; //Brother[] sort = new Brother[3]; String[] index = {"A","B","C"}; for (int i = 0; i < 3; i++) { brother[i] = new Brother(sc.nextInt(),sc.nextInt(),index[i]); } do { check = false; if (brother[0].cm == brother[1].cm) { if(brother[0].kg > brother[1].kg) { tmp = brother[0]; brother[0] = brother[1]; brother[1] = tmp; check = true; } } if (brother[1].cm == brother[2].cm) { if(brother[1].kg > brother[2].kg) { tmp = brother[1]; brother[1] = brother[2]; brother[2] = tmp; check = true; } } if (brother[0].cm == brother[2].cm) { if(brother[0].kg > brother[2].kg) { tmp = brother[2]; brother[2] = brother[0]; brother[0] = tmp; check = true; } } } while (check); Arrays.sort( brother, (a,b)-> b.cm - a.cm ); for(int i = 0; i < brother.length; i++) { System.out.println(brother[i].name); } } }