#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
bool compare(string str1, string str2) {
int len1 = str1.size();
int len2 = str2.size();
int i = 0;
while (1) {
if (i >= len1 || i >= len2)
break;
if (str1[i] < str2[i])
return true;
else if (str1[i] > str2[i])
return false;
else
i++;
}
if (str1.size() < str2.size())
return true;
else
return false;
}
int main()
{
string input;
vector <string> str_vec;
vector <int> num_vec;
string tmp;
int count;
int max_len;
vector <string> elem_vec;
while (cin >> input) {
str_vec.clear();
num_vec.clear();
tmp.clear();
count = 0;
max_len = 0;
for (int i = 0; i < input.size(); i++) {
if (input[i] >= 'a' && input[i] <= 'z') {
if (count > 0) {
str_vec.push_back(tmp);
num_vec.push_back(count);
tmp.clear();
count = 0;
}
tmp += input[i];
}
else if (input[i] >= '0' && input[i] <= '9'){
count += (count * 10 + input[i] - '0');
if (count > max_len)
max_len = count;
}
else {
continue;
}
}
if (tmp.size() > 0 && count > 0) {
str_vec.push_back(tmp);
num_vec.push_back(count);
tmp.clear();
count = 0;
if (count > max_len)
max_len = count;
}
elem_vec.clear();
string elem;
for (int i = 0; i <= max_len; i++) {
for (int j = 0; j < str_vec.size(); j++) {
if (num_vec[j] == i) {
elem_vec.push_back(str_vec[j]);
}
}
sort(elem_vec.begin(), elem_vec.end(), compare);
//sort(elem_vec.begin(), elem_vec.end());
for (int m = 0; m < elem_vec.size(); m++) {
for (int n = 0; n < i; n++)
cout << elem_vec[m];
}
elem_vec.clear();
}
cout << endl;
cout << "---------------------------" << endl;
}
}