#include<bits/stdc++.h>
using namespace std;
int n,numm,ccd,post[100001],ins[100001],dd[100001],a,b,c,d;
char s[1001];
map<char,int>mp,meet1,inq,inq2;
struct node{
char c1;int w1;
friend bool operator < (node aa,node bb){
return aa.w1<bb.w1;
}
};
int main(){
cin>>n;
scanf("%s",s);
int ii=0;
while(ii<strlen(s)-1){
int yyy=1;
while(s[ii]==s[ii+1]){
ii++;yyy++;}
ii++;
if(!meet1[s[ii]])meet1[s[ii]]=ii;
//cout<<"yu"<<endl;
mp[s[ii-1]]+=(yyy/n);
if(yyy%n!=0){
if(!inq2[s[ii-1]]){
ccd++;
inq2[s[ii-1]]=ccd;}
}
}
node ttty[3000];int kk1=0,km1=0;
for(map<char,int>::iterator it=mp.begin();it!=mp.end();it++){
// cout<<it->first<<" "<<it->second<<endl;
if(!inq2[it->first]&&mp[it->first]){
//printf("%c",it->first);
ttty[++kk1].c1=it->first;
km1++;
if(!inq[it->first])
inq[it->first]=km1;
ttty[kk1].w1=meet1[it->first];
}
}
sort(ttty+1,ttty+1+kk1);
for(int i=1;i<=kk1;i++)cout<<ttty[i].c1;
cout<<endl;
ii=0;
while(ii<strlen(s)){
if(inq[s[ii]]){
int ok=1;
for(int j=ii;j<=ii+n-1;j++)if(s[j]!=s[ii])ok=0;
if(ok){
printf("%c",s[ii]);
ii=ii+n-1;
}
}
else printf("%c",s[ii]);
++ii;
}
return 0;
}
!!!测试点2,4:注意输出可能坏键的字符顺序是按照字符串中出现的顺序。