package net.ipipip0129.yukicoder.no571; import java.util.*; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); List humanList = new ArrayList<>(); final String[] names = new String[] {"A", "B", "C"}; for (int i = 0; i < 3; i++) { String[] datas = scan.nextLine().split(" "); humanList.add(new Human(names[i], Integer.parseInt(datas[0]), Integer.parseInt(datas[1]))); } Collections.sort(humanList, new HumanComparator()); humanList.stream().forEach(i -> System.out.println(i.getName())); } } class Human { private String name; private int height; private int weight; public Human(String name, int height, int weight) { this.name = name; this.height = height; this.weight = weight; } public String getName() { return name; } public int getHeight() { return height; } public int getWeight() { return weight; } } class HumanComparator implements Comparator { @Override public int compare(Human o1, Human o2) { if (o1.getHeight() < o2.getHeight()) { return 1; } else if(o1.getHeight() == o2.getHeight()) { if (o2.getWeight() < o1.getWeight()) { return 1; }else { return -1; } } else { return -1; } } }