#include <bits/stdc++.h>
using namespace std;
vector<string> name[30], sur[30];
int cnt[30], cntN[30], cntS[30];
vector<pair<string, string> > sltn;
int main() {
  int i, j, k, cs, t, n;
  string s;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    cin >> s;
    name[s[0] - 'A'].push_back(s);
    cntN[s[0] - 'A']++;
  }
  for (i = 1; i <= n; i++) {
    cin >> s;
    sur[s[0] - 'A'].push_back(s);
    cntS[s[0] - 'A']++;
  }
  for (i = 0; i <= 25; i++) {
    sort(name[i].begin(), name[i].end());
    sort(sur[i].begin(), sur[i].end());
    cnt[s[0] - 'A'] = min(cntN[s[0] - 'A'], cntS[s[0] - 'A']);
  }
  for (i = 0; i <= 25; i++) {
    if (name[i].size() <= sur[i].size()) {
      while (name[i].size()) {
        sltn.push_back({name[i][0], sur[i][0]});
        name[i].erase(name[i].begin());
        sur[i].erase(sur[i].begin());
      }
    } else {
      for (j = 0; j < i; j++) {
        if (name[i].size() == sur[i].size()) break;
        while (sur[j].size()) {
          if (name[i].size() == sur[i].size()) break;
          sltn.push_back({name[i][0], sur[j][0]});
          name[i].erase(name[i].begin());
          sur[j].erase(sur[j].begin());
        }
      }
      while (sur[i].size()) {
        sltn.push_back({name[i][0], sur[i][0]});
        name[i].erase(name[i].begin());
        sur[i].erase(sur[i].begin());
      }
      for (j = 0; j <= 25; j++) {
        while (name[i].size() && sur[j].size()) {
          if (i < j) {
            if (cntN[j] >= sur[j].size()) break;
          }
          sltn.push_back({name[i][0], sur[j][0]});
          name[i].erase(name[i].begin());
          sur[j].erase(sur[j].begin());
        }
        if (!name[i].size()) break;
      }
    }
  }
  for (i = 0; i < sltn.size(); i++) {
    if (i) cout << " ";
    cout << sltn[i].first << " " << sltn[i].second;
    if (i != (int)sltn.size() - 1) cout << ",";
  }
  cout << endl;
  return 0;
}
