#include <bits/stdc++.h>
using namespace std;
string name[103];
string sur_name[103];
string tem[103];
void mergesort(string *a, string *b, int n) {
  int i, i0, i1, iRight, iEnd, width, j;
  for (width = 1; width < n; width *= 2)
    for (i = 0; i + width < n; i += width * 2) {
      i0 = i;
      i1 = iRight = i + width;
      iEnd = min(i + width * 2, n);
      for (j = i; i0 < iRight; j++)
        if (i1 == iEnd || a[i0] < a[i1])
          b[j] = a[i0++];
        else
          b[j] = a[i1++];
      for (j = i; j < i1; j++) a[j] = b[j];
    }
}
bool flag[103];
struct par {
  string name, sur_name;
};
par ans[103];
int coun_name[303];
int coun_sur_name[303];
int main() {
  int n;
  cin >> n;
  int i, j;
  for (i = 0; i < n; i++) {
    cin >> name[i];
    coun_name[name[i][0]]++;
  }
  for (i = 0; i < n; i++) {
    cin >> sur_name[i];
    coun_sur_name[sur_name[i][0]]++;
  }
  mergesort(name, tem, n);
  mergesort(sur_name, tem, n);
  string test1, test2;
  int ind1, ind2;
  for (i = 0; i < n; i++) {
    ans[i].name = name[i];
    test1 = test2 = "{";
    ind1 = ind2 = -1;
    for (j = 0; j < n; j++) {
      if (!flag[j] && test1 == "{" && sur_name[j][0] == name[i][0]) {
        test1 = sur_name[j];
        ind1 = j;
      }
      if (!flag[j] && test2 == "{" && sur_name[j][0] != name[i][0] &&
          coun_name[sur_name[j][0]] < coun_sur_name[sur_name[j][0]]) {
        test2 = sur_name[j];
        ind2 = j;
      }
    }
    if (coun_name[name[i][0]] <= coun_sur_name[name[i][0]]) {
      flag[ind1] = true;
      ans[i].sur_name = sur_name[ind1];
      coun_sur_name[name[i][0]]--;
    } else {
      if (test1 < test2) {
        flag[ind1] = true;
        ans[i].sur_name = sur_name[ind1];
        coun_sur_name[name[i][0]]--;
      } else {
        flag[ind2] = true;
        ans[i].sur_name = sur_name[ind2];
        coun_sur_name[sur_name[ind2][0]]--;
      }
    }
    coun_name[name[i][0]]--;
  }
  for (i = 0; i < n - 1; i++)
    cout << ans[i].name << " " << ans[i].sur_name << ", ";
  cout << ans[i].name << " " << ans[i].sur_name << endl;
  return 0;
}
