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()); String k1 = ""; int v1 = 0; for (int i=0; i entry : map.entrySet()) { if (entry.getValue()==list.get(i) && entry.getKey().equals(k1)==false) { System.out.println(entry.getKey()+" "+entry.getValue()); k1 = entry.getKey(); break; } } if (i==9) {break;} } } }