Democratic Naming

시간 제한1초메모리 제한1024 MB

요약
n개 도시 이름의 각 m개 위치에서 가장 많은 표를 받은 알파벳을 고르고, 동점이면 사전순으로 앞선 글자를 택해 새 이름을 만든다.
난이도

쉬움10점 중 3점

유형
문자열, 해시맵, 구현, 정렬
정답자
아직 제출이 없습니다

문제

A new county has been created on artificially created land out from the coast, with code name "Built Anew Peninsula County", but the final name still needs to be chosen. To establish a new name, the cities within the county get to vote on the individual letters of the name.

As it happens, all cities in the county have a name with exactly mm letters, and so they decide the name of the county will also have exactly mm letters. Naturally, each city prefers their own name, and thus votes that the iith letter of the county name should match theirs. For each of the mm positions, the letter that received the most votes across all cities gets picked. In case of a tie between multiple letters, the one occurring earliest in the English alphabet gets picked.

Given the list of the city names, determine the result of the vote for the new county's name.

입력

The input consists of:

  • One line with two integers nn and mm (1≤n≤10001\leq n\leq 1000, 1≤m≤10001 \leq m \leq 1000), the number of cities and the number of letters in each city name.
  • nn lines, each with a string of length mm, the name of a city.

The city names only consist of lowercase English letters (a-z).

출력

Output the name of the new county.

예제2

  1. 예제 1

    입력
    3 5
    apple
    maple
    alpha
    
    예상 출력
    aaple
    
  2. 예제 2

    입력
    3 4
    icpc
    back
    laps
    
    예상 출력
    bapc