import java.util.*; public class Main { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int n = sc.nextInt(); Map map = new TreeMap<>(); List list = new ArrayList<>(); for (int i=0; i entry : map.entrySet()) { list.add(entry.getValue()); } Collections.sort(list,Comparator.reverseOrder()); List list2 = new ArrayList<>(); for (int i=0; i entry : map.entrySet()) { if (entry.getValue()==list.get(i) && list2.contains(entry.getKey())==false) { System.out.println(entry.getKey()+" "+entry.getValue()); list2.add(entry.getKey()); break; } } if (i==9) {break;} } } }