#include <bits/stdc++.h>
using namespace std;
int n, cnt[198];
string s[108], s1;
set<string> F[102];
struct Tprogram {
  void open() {
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
  }
  void close() {}
  void init() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) cin >> s[i];
    for (int i = 1; i <= n; i++) {
      cin >> s1;
      F[s1[0]].insert(s1);
    }
    sort(s + 1, s + n + 1);
  }
  void work() {
    for (int i = 1; i <= n; i++) cnt[s[i][0]]++;
    for (int i = 1; i <= n; i++) {
      cout << s[i] << " ";
      char t = s[i][0];
      if (cnt[t] <= F[t].size()) {
        cout << *F[t].begin();
        F[t].erase(F[t].begin());
      } else {
        for (int i = 'A'; i <= 'Z'; i++)
          if (F[i].size() > cnt[i] || i == t && F[i].size()) {
            cout << *F[i].begin();
            F[i].erase(F[i].begin());
            goto die;
          }
      die:;
      }
      cnt[t]--;
      if (i != n) cout << ", ";
    }
  }
} Program;
int main() {
  Program.init();
  Program.work();
  return 0;
}
