import Control.Monad
import Data.List

comp x y 
  | length x == length y = EQ
  | length x < length y = GT
  | otherwise = LT
p  x = sortBy comp $ group $ sort  x

solve x = let lp = p x
              max = length $ head lp
          in  head <$> takeWhile ((== max) . length) lp

main = do
  n <- readLn
  xs <- replicateM n getLine
  putStr $ unlines $ solve xs
