#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
int main()
{
int n;
while(cin >> n)
{
vector<string> arr(n);
for(int i = 0; i < n; i++)
{
cin >> arr[i];
}
map<int, string> mp;
for(int i = 0; i < n; i++)
{
string str = arr[i];
string letters = "";
string numbers = "";
for(char c : str)
{
if(isdigit(c))
{
numbers += c;
}
else if(isalpha(c))
{
letters += c;
}
}
int num = stoi(numbers);
mp[num] = letters;
}
vector<int> keys;
for(auto entry : mp)
{
keys.push_back(entry.first);
}
sort(keys.begin(), keys.end());
for(int i = 0; i < n; i++)
{
cout << mp[keys[i]] << " ";
}
cout << endl;
}
return 0;
}