#include<bits/stdc++.h>
using namespace std;
#define rep(x,y,z) for(int (x)=(y);(x)<(z);i++)
#define mst(x,y) memset(x,y,sizeof(x))
#define ll long long
const int maxn=1e4+10;
#define pii pair<int,int>
#define piii pair<int,pii>
#define fi first
#define se second
#define mk(x,y) make_pair(x,y)
int gcd(int x,int y){
return y?gcd(y,x%y):x;
}
int k;
string s;
int abc[26],num[10],dot=0;
map<char,int> mp;
string ans="";
int main(){
cin>>k>>s;
for(int i=0;i<s.size();i++){
int cnt=1;
while(i+1<s.size()&&s[i+1]==s[i]) cnt++,i++;
if(s[i]>='0'&&s[i]<='9'){
num[s[i]-'0']=gcd(num[s[i]-'0'],cnt);
}else if(s[i]<='z'&&s[i]>='a'){
abc[s[i]-'a']=gcd(abc[s[i]-'a'],cnt);
}else{
dot=gcd(dot,cnt);
}
}
rep(i,0,s.size()){
if(mp[s[i]]) continue;
if(s[i]>='0'&&s[i]<='9'){
if(num[s[i]-'0']%k==0){
mp[s[i]]=1;
ans+=s[i];
}
}else if(s[i]<='z'&&s[i]>='a'){
if(abc[s[i]-'a']%k==0){
mp[s[i]]=1;
ans+=s[i];
}
}else{
if(dot%k==0) {
mp[s[i]]=1;
ans+=s[i];
}
}
}
cout<<ans<<endl;
rep(i,0,s.size()){
cout<<s[i];
if(mp[s[i]]) i+=k-1;
}
cout<<endl;
return 0;
}