#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<set<string> > N, F;
  vector<pair<string, string> > ans;
  set<string> p;
  for (int i = 0; i < 26; ++i) {
    N.push_back(p);
    F.push_back(p);
  }
  int n, k, c;
  cin >> n;
  c = (int)'A';
  string s;
  for (int i = 0; i < n; ++i) {
    cin >> s;
    k = (int)s[0];
    N[k - c].insert(s);
  }
  for (int i = 0; i < n; ++i) {
    cin >> s;
    k = (int)s[0];
    F[k - c].insert(s);
  }
  queue<string> qN, qF;
  set<string>::iterator el, el1;
  for (int i = 0; i < 26; ++i) {
    if (N[i].size() <= F[i].size()) {
      while (N[i].size() < F[i].size() && !qN.empty()) {
        el = F[i].begin();
        ans.push_back(make_pair(qN.front(), *el));
        F[i].erase(el);
        qN.pop();
      }
      while (!N[i].empty()) {
        el = F[i].begin();
        el1 = N[i].begin();
        ans.push_back(make_pair(*el1, *el));
        F[i].erase(el);
        N[i].erase(el1);
      }
      while (!F[i].empty()) {
        el = F[i].begin();
        qF.push(*el);
        F[i].erase(el);
      }
    } else {
      while (F[i].size() < N[i].size() && !qF.empty()) {
        el = N[i].begin();
        ans.push_back(make_pair(*el, qF.front()));
        N[i].erase(el);
        qF.pop();
      }
      while (!F[i].empty()) {
        el = F[i].begin();
        el1 = N[i].begin();
        ans.push_back(make_pair(*el1, *el));
        F[i].erase(el);
        N[i].erase(el1);
      }
      while (!N[i].empty()) {
        el = N[i].begin();
        qN.push(*el);
        N[i].erase(el);
      }
    }
  }
  sort(ans.begin(), ans.end());
  int i;
  for (i = 0; i < ans.size() - 1; ++i)
    cout << ans[i].first << " " << ans[i].second << ", ";
  cout << ans[i].first << " " << ans[i].second;
  return 0;
}
