#include <bits/stdc++.h>
using namespace std;
const int maxn = 26;
int n;
string s;
vector<pair<string, string> > ans;
set<string> name[maxn], snam[maxn];
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    name[s[0] - 'A'].insert(s);
  }
  for (int i = 0; i < n; i++) {
    cin >> s;
    snam[s[0] - 'A'].insert(s);
  }
  for (int i = 0; i < 26; i++) {
    while (!name[i].empty() && !snam[i].empty()) {
      ans.push_back(make_pair(*(name[i].begin()), *(snam[i].begin())));
      name[i].erase(name[i].begin());
      snam[i].erase(snam[i].begin());
    }
    while (!name[i].empty()) {
      bool flg = 0;
      for (int j = i + 1; j < 26; j++) {
        while (((int(name[j].size()))) < ((int(snam[j].size())))) {
          ans.push_back(make_pair(*(name[i].begin()), *(snam[j].begin())));
          name[i].erase(name[i].begin());
          snam[j].erase(snam[j].begin());
          if (name[i].empty()) {
            flg = 1;
            break;
          }
        }
        if (flg) break;
      }
    }
    while (!snam[i].empty()) {
      bool flg = 0;
      for (int j = i + 1; j < 26; j++) {
        while (((int(name[j].size()))) > ((int(snam[j].size())))) {
          ans.push_back(make_pair(*(name[j].begin()), *(snam[i].begin())));
          snam[i].erase(snam[i].begin());
          name[j].erase(name[j].begin());
          if (snam[i].empty()) {
            flg = 1;
            break;
          }
        }
        if (flg) break;
      }
    }
  }
  sort(ans.begin(), ans.end());
  for (int i = 0; i < n; i++) {
    cout << ans[i].first << " " << ans[i].second;
    if (i < n - 1) cout << ", ";
  }
  return 0;
}
