#include <bits/stdc++.h>
using namespace std;
const int ENGCHNUM = 26;
vector<string> name, surname;
int ccnt0[ENGCHNUM], ccnt1[ENGCHNUM];
bool comp(string st0, string st1) { return st0 < st1; }
int main() {
  int n;
  bool first;
  string st;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> st, name.push_back(st), ccnt0[st[0] - 'A']++;
  for (int i = 0; i < n; i++)
    cin >> st, surname.push_back(st), ccnt1[st[0] - 'A']++;
  sort(name.begin(), name.end(), comp);
  sort(surname.begin(), surname.end(), comp);
  first = true;
  for (vector<string>::iterator iter0 = name.begin(); iter0 != name.end();
       iter0++) {
    string st0 = *iter0;
    string st1;
    vector<string>::iterator savediter;
    for (vector<string>::iterator iter1 = surname.begin();
         iter1 != surname.end(); iter1++) {
      string temst = *iter1;
      if (temst[0] == st0[0] || ccnt1[temst[0] - 'A'] > ccnt0[temst[0] - 'A'] &&
                                    ccnt0[st0[0] - 'A'] > ccnt1[st0[0] - 'A']) {
        st1 = temst;
        savediter = iter1;
        break;
      }
    }
    surname.erase(savediter);
    ccnt0[st0[0] - 'A']--;
    ccnt1[st1[0] - 'A']--;
    if (first)
      first = false;
    else
      cout << ", ";
    cout << st0 << " " << st1;
  }
  return 0;
}
