#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<string> name(n), surname(n), fullname;
  vector<int> length1(26, 0), length2(26, 0);
  for (int i = 0; i < n; length1[name[i][0] - 'A']++, i++) {
    cin >> name[i];
  }
  for (int i = 0; i < n; length2[surname[i][0] - 'A']++, i++) {
    cin >> surname[i];
  }
  sort(name.begin(), name.end());
  sort(surname.begin(), surname.end());
  while (fullname.size() != n) {
    if (length1[name[0][0] - 'A'] > length2[name[0][0] - 'A'] &&
        length1[surname[0][0] - 'A'] < length2[surname[0][0] - 'A']) {
      fullname.push_back(name[0] + ' ' + surname[0]);
      length1[name[0][0] - 'A']--;
      length2[surname[0][0] - 'A']--;
      name.erase(name.begin());
      surname.erase(surname.begin());
    } else if (name[0][0] > surname[0][0]) {
      for (int i = 0; i < surname.size(); i++) {
        if (name[0][0] == surname[i][0]) {
          fullname.push_back(name[0] + ' ' + surname[i]);
          length1[name[0][0] - 'A']--;
          length2[name[0][0] - 'A']--;
          name.erase(name.begin());
          surname.erase(surname.begin() + i);
          break;
        }
      }
    } else {
      for (int i = 0; i < name.size(); i++) {
        if (name[i][0] == surname[0][0]) {
          fullname.push_back(name[i] + ' ' + surname[0]);
          length1[surname[0][0] - 'A']--;
          length2[surname[0][0] - 'A']--;
          name.erase(name.begin() + i);
          surname.erase(surname.begin());
          break;
        }
      }
    }
  }
  sort(fullname.begin(), fullname.end());
  for (int i = 0; i < n - 1; i++) {
    cout << fullname[i] << ", ";
  }
  cout << fullname[n - 1];
}
