#include <bits/stdc++.h>
using namespace std;
int N, i, id, first;
string Name[105], Suname[105];
int NextName[105], NextSuname[105];
int SonName[128], SonSuname[128];
int CntName[128], CntSuname[128];
int link[128];
int cmp(const string &a, const string &b) { return a > b; }
int main() {
  scanf("%d", &N);
  for (i = 1; i <= N; ++i) cin >> Name[i];
  for (i = 1; i <= N; ++i) cin >> Suname[i];
  sort(Name + 1, Name + N + 1, cmp);
  sort(Suname + 1, Suname + N + 1, cmp);
  for (i = 1; i <= N; ++i) {
    NextName[i] = SonName[Name[i][0]];
    SonName[Name[i][0]] = i;
    ++CntName[Name[i][0]];
  }
  for (i = 1; i <= N; ++i) {
    NextSuname[i] = SonSuname[Suname[i][0]];
    SonSuname[Suname[i][0]] = i;
    ++CntSuname[Suname[i][0]];
  }
  for (i = 'Z'; i >= 'A'; --i)
    if (CntSuname[i] > CntName[i]) {
      link[i] = first;
      first = i;
    }
  id = 0;
  for (i = 'A'; i <= 'z'; ++i) {
    for (; CntName[i] > CntSuname[i] && first < i;) {
      if (id) printf(", ");
      ++id;
      cout << Name[SonName[i]] << " " << Suname[SonSuname[first]];
      --CntName[i], --CntSuname[first];
      SonName[i] = NextName[SonName[i]],
      SonSuname[first] = NextSuname[SonSuname[first]];
      if (!CntSuname[first]) first = link[first];
    }
    for (; CntName[i] && CntSuname[i];) {
      if (id) printf(", ");
      ++id;
      cout << Name[SonName[i]] << " " << Suname[SonSuname[i]];
      --CntName[i], --CntSuname[i];
      SonName[i] = NextName[SonName[i]],
      SonSuname[i] = NextSuname[SonSuname[i]];
    }
    for (; CntName[i];) {
      if (id) printf(", ");
      ++id;
      cout << Name[SonName[i]] << " " << Suname[SonSuname[first]];
      --CntName[i], --CntSuname[first];
      SonName[i] = NextName[SonName[i]],
      SonSuname[first] = NextSuname[SonSuname[first]];
      if (CntName[first] == CntSuname[first]) first = link[first];
    }
  }
  printf("\n");
  return 0;
}
