#include <bits/stdc++.h>
using namespace std;
const int ALP = 'Z' - 'A' + 1 + 5;
vector<string> sur[ALP + 5], name[ALP + 5];
vector<pair<int, int> > ret[ALP + 5];
int ps[ALP + 5];
int num[ALP + 5];
int n;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    string tmp;
    cin >> tmp;
    name[tmp[0] - 'A'].push_back(tmp);
  }
  for (int i = 0; i < n; i++) {
    string tmp;
    cin >> tmp;
    sur[tmp[0] - 'A'].push_back(tmp);
  }
  for (int i = 0; i < ALP; i++) {
    sort(sur[i].begin(), sur[i].end());
    sort(name[i].begin(), name[i].end());
    num[i] = (int)sur[i].size() - (int)name[i].size();
  }
  int p = 0;
  while ((ps[p] == (int)sur[p].size() || num[p] <= 0) && p < ALP) p++;
  for (int i = 0; i < ALP; i++) {
    for (int j = 0; j < (int)name[i].size(); j++) {
      if (num[i] >= 0)
        ret[i].push_back(pair<int, int>(i, ps[i]++));
      else {
        if ((int)name[i].size() - j > (int)sur[i].size() - ps[i]) {
          if (p < i || ps[i] == (int)sur[i].size()) {
            ret[i].push_back(pair<int, int>(p, ps[p]++));
            num[i]++;
            num[p]--;
          } else
            ret[i].push_back(pair<int, int>(i, ps[i]++));
        } else
          ret[i].push_back(pair<int, int>(i, ps[i]++));
      }
      while ((ps[p] == (int)sur[p].size() || num[p] <= 0) && p < ALP) p++;
    }
  }
  int cnt = 0;
  for (int i = 0; i < ALP; i++)
    for (int j = 0; j < (int)name[i].size(); j++) {
      cout << name[i][j] << " ";
      cout << sur[ret[i][j].first][ret[i][j].second];
      cnt++;
      if (cnt != n) cout << ", ";
    }
  cout << endl;
  return 0;
}
