#include <iostream>
#include <map>
#include <string>
using namespace std;
int main()
{
int k;
string s;
map<char, bool> ma;
map<char, bool> mb;
cin >> k >> s;
for(int i = 1; i < s.length(); i++){
int cnt = 1;
while(s[i] == s[i-1] && i < s.length()){
i++;
cnt++;
}
if(cnt % k == 0){
ma[s[i-1]] = true;
}else{
ma[s[i-1]] = false;
}
}
for(int i = 0; i < s.length(); i++){
if(ma[s[i]] && !mb[s[i]]){
cout << s[i];
mb[s[i]] = true;
}
}
cout << endl;
for(int i = 0; i < s.length(); ){
if(ma[s[i]] ){
cout << s[i];
i = i + k;
}else{
cout << s[i];
i++;
}
}
cout << endl;
return 0;
}