#include <bits/stdc++.h>
using namespace std;
vector<string> fam;
vector<string> name;
map<char, int> letfam;
map<char, int> letname;
map<char, int> kol;
vector<bool> used;
int n;
int main() {
  cin >> n;
  fam.resize(n);
  name.resize(n);
  for (char ch = 'A'; ch <= 'Z'; ch++) letname[ch] = letfam[ch] = kol[ch] = 0;
  for (int i = 0; i < n; i++) cin >> name[i], letname[name[i][0]]++;
  for (int i = 0; i < n; i++) cin >> fam[i], letfam[fam[i][0]]++;
  for (char ch = 'A'; ch <= 'Z'; ch++) kol[ch] = min(letname[ch], letfam[ch]);
  sort(name.begin(), name.end());
  sort(fam.begin(), fam.end());
  used.assign(n, false);
  for (int i = 0; i < n; i++) {
    int pair2 = -1;
    for (int j = 0; j < n; j++)
      if (!used[j] &&
          (((kol[fam[j][0]] ==
             min(letname[fam[j][0]], letfam[fam[j][0]] - 1)) &&
            (kol[name[i][0]] ==
             min(letname[name[i][0]] - 1, letfam[name[i][0]]))) ||
           (name[i][0] == fam[j][0])) &&
          pair2 == -1)
        pair2 = j;
    cout << name[i] << ' ' << fam[pair2] << ((i != n - 1) ? ", " : "");
    letname[name[i][0]]--;
    letfam[fam[pair2][0]]--;
    kol[name[i][0]] = min(letname[name[i][0]], letfam[name[i][0]]);
    kol[fam[pair2][0]] = min(letname[fam[pair2][0]], letfam[fam[pair2][0]]);
    used[pair2] = true;
  }
}
