#include <iostream>
#include <cstring>
using namespace std;
struct SuffixArray{
#ifndef _SA_
#define maxn 1200000
#define maxcnt 270
#endif
int n;
int sa[maxn];
int rk[maxn];
int ssa[maxn];
int srk[maxn];
int cnt[maxn];
int height[maxn];
void doubling(string s, int m)
{
memset(cnt, 0, sizeof(cnt));
for(int i=0; i<s.length(); ++i) ++cnt[ rk[i] = s[i] ];
for(int i=1; i<m; ++i) cnt[i] += cnt[i-1];
for(int i=s.length()-1; i>=0; --i) sa[ --cnt[s[i]] ] = i;
for(int j=1, kk=1; kk < s.length(); j<<=1, m=kk)
{
int i;
for(i=s.length()-j, kk=0; i < s.length(); ++i) ssa[kk++] = i;
for(i=0; i < s.length(); ++i) if(sa[i] >= j) ssa[kk++] = sa[i] - j;
for(i=0; i < s.length(); ++i) srk[i] = rk[ssa[i]];
memset(cnt, 0, sizeof(cnt));
for(i=0; i<s.length(); ++i) ++cnt[ srk[i] ];
for(i=1; i<m; ++i) cnt[i] += cnt[i-1];
for(i=s.length()-1; i>=0; --i) sa[ --cnt[srk[i]] ] = ssa[i];
memcpy(srk, rk, sizeof(rk));
for( rk[sa[0]] = 0, kk = 1, i = 1; i < s.length(); ++i )
{
rk[sa[i]] = (srk[sa[i-1]] == srk[sa[i]] && sa[i-1] + j < s.length() && sa[i] + j < s.length() && srk[sa[i-1] + j] == srk[sa[i] + j] )?kk-1:kk++;
}
}
}
void generateHeight(string s)
{
int i, j, kk = 0;
for(i=0; i<s.length(); height[rk[i++]] = kk)
{
if(rk[i]) for(kk?kk--:0, j = sa[rk[i]-1]; i+kk < s.length() && j+kk < s.length() && s[i+kk] == s[j+kk]; ++kk);
}
}
};
static SuffixArray sa;
int main()
{
ios::sync_with_stdio(false);
int N;
string s;
cin>>N;
getline(cin, s);
getline(cin, s);
sa.doubling(s, 130);
sa.generateHeight(s);
int idx = sa.sa[0], ans = 0, maxL = 0;
for(int i=1; i<s.length(); ++i)
{
if(sa.height[i]>=N)
{
ans++;
}
else
{
ans = 0;
}
if(ans > maxL && s.length()-sa.sa[i] >= N)
{
maxL = ans;
idx = sa.sa[i];
}
}
cout<<s.substr(idx, N)<<" "<<maxL+1<<endl;
return 0;
}