import java.util.*;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static java.util.Map.Entry.comparingByKey;
import static java.util.Map.Entry.comparingByValue;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.nextLine());

        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            String s = sc.nextLine();

            Integer c = map.get(s);
            if(c == null){
                map.put(s, 0);
            } else {
                map.put(s, c+1);
            }
        }

        List<Map.Entry<String, Integer>> collect = map.entrySet().stream()
                .sorted(comparingByKey())
                .sorted(Collections.reverseOrder(comparingByValue()))
                .collect(Collectors.toList());

        int max = 0;
        for (Map.Entry<String, Integer> e : collect) {
            if(max <= e.getValue()){
                max = e.getValue();
                System.out.println(e.getKey());
            } else {
                break;
            }
        }
    }
} import java.util.*; util.* java import java.util.function.Predicate; Predicate java.util.function import java.util.stream.Collectors; Collectors java.util.stream import java.util.stream.Stream; Stream java.util.stream import static java.util.Map.Entry.comparingByKey; import static java.util.Map.Entry.comparingByKey; import static java.util.Map.Entry.comparingByKey; import static java.util.Map.Entry.comparingByValue; import static java.util.Map.Entry.comparingByValue; import static java.util.Map.Entry.comparingByValue; public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.nextLine());

        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            String s = sc.nextLine();

            Integer c = map.get(s);
            if(c == null){
                map.put(s, 0);
            } else {
                map.put(s, c+1);
            }
        }

        List<Map.Entry<String, Integer>> collect = map.entrySet().stream()
                .sorted(comparingByKey())
                .sorted(Collections.reverseOrder(comparingByValue()))
                .collect(Collectors.toList());

        int max = 0;
        for (Map.Entry<String, Integer> e : collect) {
            if(max <= e.getValue()){
                max = e.getValue();
                System.out.println(e.getKey());
            } else {
                break;
            }
        }
    }
} Main public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.nextLine());

        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            String s = sc.nextLine();

            Integer c = map.get(s);
            if(c == null){
                map.put(s, 0);
            } else {
                map.put(s, c+1);
            }
        }

        List<Map.Entry<String, Integer>> collect = map.entrySet().stream()
                .sorted(comparingByKey())
                .sorted(Collections.reverseOrder(comparingByValue()))
                .collect(Collectors.toList());

        int max = 0;
        for (Map.Entry<String, Integer> e : collect) {
            if(max <= e.getValue()){
                max = e.getValue();
                System.out.println(e.getKey());
            } else {
                break;
            }
        }
    } main {

        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.nextLine());

        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            String s = sc.nextLine();

            Integer c = map.get(s);
            if(c == null){
                map.put(s, 0);
            } else {
                map.put(s, c+1);
            }
        }

        List<Map.Entry<String, Integer>> collect = map.entrySet().stream()
                .sorted(comparingByKey())
                .sorted(Collections.reverseOrder(comparingByValue()))
                .collect(Collectors.toList());

        int max = 0;
        for (Map.Entry<String, Integer> e : collect) {
            if(max <= e.getValue()){
                max = e.getValue();
                System.out.println(e.getKey());
            } else {
                break;
            }
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.nextLine()); N Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc Map<String, Integer> map = new HashMap<>(); map new HashMap<>() for (int i = 0; i < N; i++) {
            String s = sc.nextLine();

            Integer c = map.get(s);
            if(c == null){
                map.put(s, 0);
            } else {
                map.put(s, c+1);
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            String s = sc.nextLine();

            Integer c = map.get(s);
            if(c == null){
                map.put(s, 0);
            } else {
                map.put(s, c+1);
            }
        } {
            String s = sc.nextLine();

            Integer c = map.get(s);
            if(c == null){
                map.put(s, 0);
            } else {
                map.put(s, c+1);
            }
        } String s = sc.nextLine(); s sc.nextLine() sc.nextLine sc Integer c = map.get(s); c map.get(s) map.get map s if(c == null){
                map.put(s, 0);
            } else {
                map.put(s, c+1);
            } c == null c null {
                map.put(s, 0);
            } map.put(s, 0) map.put map s 0 {
                map.put(s, c+1);
            } map.put(s, c+1) map.put map s c+1 c 1 List<Map.Entry<String, Integer>> collect = map.entrySet().stream()
                .sorted(comparingByKey())
                .sorted(Collections.reverseOrder(comparingByValue()))
                .collect(Collectors.toList()); collect map.entrySet().stream()
                .sorted(comparingByKey())
                .sorted(Collections.reverseOrder(comparingByValue()))
                .collect(Collectors.toList()) map.entrySet().stream()
                .sorted(comparingByKey())
                .sorted(Collections.reverseOrder(comparingByValue()))
                .collect map.entrySet().stream()
                .sorted(comparingByKey())
                .sorted(Collections.reverseOrder(comparingByValue())) map.entrySet().stream()
                .sorted(comparingByKey())
                .sorted map.entrySet().stream()
                .sorted(comparingByKey()) map.entrySet().stream()
                .sorted map.entrySet().stream() map.entrySet().stream map.entrySet() map.entrySet map comparingByKey() comparingByKey Collections.reverseOrder(comparingByValue()) Collections.reverseOrder Collections comparingByValue() comparingByValue Collectors.toList() Collectors.toList Collectors int max = 0; max 0 for (Map.Entry<String, Integer> e : collect) {
            if(max <= e.getValue()){
                max = e.getValue();
                System.out.println(e.getKey());
            } else {
                break;
            }
        } Map.Entry<String, Integer> e collect {
            if(max <= e.getValue()){
                max = e.getValue();
                System.out.println(e.getKey());
            } else {
                break;
            }
        } {
            if(max <= e.getValue()){
                max = e.getValue();
                System.out.println(e.getKey());
            } else {
                break;
            }
        } if(max <= e.getValue()){
                max = e.getValue();
                System.out.println(e.getKey());
            } else {
                break;
            } max <= e.getValue() max e.getValue() e.getValue e {
                max = e.getValue();
                System.out.println(e.getKey());
            } max = e.getValue() max e.getValue() e.getValue e System.out.println(e.getKey()) System.out.println System.out System System.out e.getKey() e.getKey e {
                break;
            } break; String[] args args public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.nextLine());

        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            String s = sc.nextLine();

            Integer c = map.get(s);
            if(c == null){
                map.put(s, 0);
            } else {
                map.put(s, c+1);
            }
        }

        List<Map.Entry<String, Integer>> collect = map.entrySet().stream()
                .sorted(comparingByKey())
                .sorted(Collections.reverseOrder(comparingByValue()))
                .collect(Collectors.toList());

        int max = 0;
        for (Map.Entry<String, Integer> e : collect) {
            if(max <= e.getValue()){
                max = e.getValue();
                System.out.println(e.getKey());
            } else {
                break;
            }
        }
    }
} public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.nextLine());

        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            String s = sc.nextLine();

            Integer c = map.get(s);
            if(c == null){
                map.put(s, 0);
            } else {
                map.put(s, c+1);
            }
        }

        List<Map.Entry<String, Integer>> collect = map.entrySet().stream()
                .sorted(comparingByKey())
                .sorted(Collections.reverseOrder(comparingByValue()))
                .collect(Collectors.toList());

        int max = 0;
        for (Map.Entry<String, Integer> e : collect) {
            if(max <= e.getValue()){
                max = e.getValue();
                System.out.println(e.getKey());
            } else {
                break;
            }
        }
    }
} Main
import java.util.*;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static java.util.Map.Entry.comparingByKey;
import static java.util.Map.Entry.comparingByValue;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.nextLine());

        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            String s = sc.nextLine();

            Integer c = map.get(s);
            if(c == null){
                map.put(s, 0);
            } else {
                map.put(s, c+1);
            }
        }

        List<Map.Entry<String, Integer>> collect = map.entrySet().stream()
                .sorted(comparingByKey())
                .sorted(Collections.reverseOrder(comparingByValue()))
                .collect(Collectors.toList());

        int max = 0;
        for (Map.Entry<String, Integer> e : collect) {
            if(max <= e.getValue()){
                max = e.getValue();
                System.out.println(e.getKey());
            } else {
                break;
            }
        }
    }
}
