#include <bits/stdc++.h>
using namespace std;
int n;
vector<string> a[30];
vector<string> b[30];
int f[30];
int p[30];
string res = "";
char s[100];
int main() {
  scanf("%d", &n);
  gets(s);
  for (int i = 0; i < n; ++i) {
    gets(s);
    a[s[0] - 'A'].push_back(s);
  }
  for (int i = 0; i < n; ++i) {
    gets(s);
    b[s[0] - 'A'].push_back(s);
  }
  for (int i = 0; i < 26; ++i) {
    sort(a[i].begin(), a[i].end());
    sort(b[i].begin(), b[i].end());
    reverse(b[i].begin(), b[i].end());
    p[i] = min(a[i].size(), b[i].size());
    f[i] = b[i].size() - p[i];
  }
  bool bb = false;
  for (int i = 0; i < 26; ++i) {
    for (int j = 0; j < a[i].size(); ++j) {
      if (bb) res += ", ";
      res += a[i][j];
      res += ' ';
      if (a[i].size() - j > p[i]) {
        int k = 0;
        for (; k < 26 && f[k] == 0; ++k)
          ;
        if (k < i || p[i] == 0) {
          res += b[k][b[k].size() - 1];
          b[k].resize(b[k].size() - 1);
          --f[k];
        } else {
          res += b[i][b[i].size() - 1];
          b[i].resize(b[i].size() - 1);
          --p[i];
        }
      } else {
        res += b[i][b[i].size() - 1];
        b[i].resize(b[i].size() - 1);
        --p[i];
      }
      bb = true;
    }
  }
  printf("%s", res.c_str());
  return 0;
}
