#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  set<string> name[26], sur[26];
  set<string> full;
  for (int i = 0; i < n; i++) {
    string x;
    cin >> x;
    name[x[0] - 'A'].insert(x);
  }
  for (int i = 0; i < n; i++) {
    string x;
    cin >> x;
    sur[x[0] - 'A'].insert(x);
  }
  for (int i = 0; i < 26; i++) {
    while (!name[i].empty() && !sur[i].empty()) {
      set<string>::iterator a = name[i].begin();
      set<string>::iterator b = sur[i].begin();
      full.insert((*a) + " " + (*b));
      name[i].erase(*a);
      sur[i].erase(*b);
    }
    if (!name[i].empty()) {
      for (int j = i + 1; j < 26 && !name[i].empty(); j++) {
        while (sur[j].size() > name[j].size() && !name[i].empty()) {
          set<string>::iterator a = name[i].begin();
          set<string>::iterator b = sur[j].begin();
          full.insert((*a) + " " + (*b));
          name[i].erase(*a);
          sur[j].erase(*b);
        }
      }
    }
    if (!sur[i].empty()) {
      for (int j = i + 1; j < 26 && !sur[i].empty(); j++) {
        while (name[j].size() > sur[j].size() && !sur[i].empty()) {
          set<string>::iterator a = name[j].begin();
          set<string>::iterator b = sur[i].begin();
          full.insert((*a) + " " + (*b));
          name[j].erase(*a);
          sur[i].erase(*b);
        }
      }
    }
  }
  for (set<string>::iterator i = full.begin(); i != full.end(); ++i) {
    cout << (*i);
    set<string>::iterator j = i;
    j++;
    if (j != full.end()) {
      cout << ", ";
    }
  }
  cout << endl;
  return 0;
}
