15
MIRZOYANOVECLOX
 23
AABBBAAACCCCCAAADDDDDDD
 2
QA
 11
GGRRAATTZZZ
 6
AZAZAZ
 10
SQSQSQSQTG
 3
KEK
 100
URXCAIZFIBNJTPCZHBQIBCILLPXZCFGMKKZMNPLCYGAVJVIBMCZEBSJWPSCPQDYCTTKPOKIJRSKIZPDGCHVOUTMPNECYORSFZFNC
 3
LOL
 2
WW
 8
PUTINVOR
 26
QWERTYUIOPASDFGHJKLZXCVBNM
 5
AZAZA
 9
EGORLETOV
 7
KADUROV
 9
MIKEPIDOR
 9
AAAAAAAAA
 100
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
 5
FUFEL
 50
NYQAHBYYOXLTRYQDMVENEMAQNBAKGLGQOLXNAIFNQTOCLNNQIA

MI
 DD
 QA
 ZZ
 AZ
 SQ
 KE
 IB
 LO
 WW
 PU
 QW
 AZ
 EG
 KA
 MI
 AA
 AA
 FU
 YQ

from functools import reduce
# import sys
# sys.stdin = open('input.txt','r')
# sys.stdout = open('output.txt','w')

###### 

# Matrix Multiplication Function 
def matmult(a,b):
   zip_b = list(zip(*b))
   return [[sum(ele_a*ele_b for ele_a, ele_b in zip(row_a, col_b))
            for col_b in zip_b] for row_a in a]

######

# isPrime
def Prime(n):
    if n & 1 == 0:
        return False
    d= 3
    while d * d <= n:
        if n % d == 0:
            return False
        d= d + 2
    return True
# This function returns True if a number is Prime else returns False

######

# factors of a number
def factors(n):    
    return set(reduce(list.__add__, 
                ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))
# This function returns set of all the factors

######
def isEven(n):
    if (n%2==0):
        return True
    return False

######

def sieve_of_eratosthenes(x , y):
    l = [2] # list of prime numbers
    for n in range(3,y+1,2): # iterations over odd numbers
        isprime = True
        for e in l:
            if n % e == 0:
                isprime = False
                break
        if(isprime):
            l.append(n)

    return [e for e in l if e >= x]

######

# for _ in range(int(input())):
n = int(input())
s = input()
#     n,k = map(int,input().split())
#     lst = list(map(int,input().split()))
d = {}
ans,val = '',0
for i in range(n-2):
    if s[i:i+2] in d.keys():
        d[s[i:i+2]]+=1
        if (d[s[i:i+2]]>val):
            val = d[s[i:i+2]]
            ans = s[i:i+2]
    else:
        d[s[i:i+2]]=1
print(ans,val)
