#include <bits/stdc++.h>
using namespace std;
int n;
set<string> x[26], y[26];
string s, t;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> s, x[s[0] - 'A'].insert(s);
  for (int i = 1; i <= n; ++i) cin >> s, y[s[0] - 'A'].insert(s);
  for (int i = 0; i < 26; ++i)
    while (x[i].size()) {
      string a = *x[i].begin();
      if (y[i].size() >= x[i].size())
        t += a + " " + *y[i].begin() + ", ", y[i].erase(y[i].begin());
      else
        for (int j = 0; j < 26; ++j)
          if (y[j].size() > x[j].size() || (j == i && y[j].size())) {
            t += a + " " + *y[j].begin() + ", ", y[j].erase(y[j].begin());
            break;
          }
      x[i].erase(x[i].begin());
    }
  t.erase(t.size() - 2);
  cout << t << endl;
  return 0;
}
