#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:64000000")
int n;
string names[1 << 7], surnames[1 << 7];
int was[1 << 7] = {0};
int cnt[1 << 7] = {0};
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    names[i] = s;
    int x = (int)(s[0] - 'A');
    --cnt[x];
  }
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    surnames[i] = s;
    int x = (int)(s[0] - 'A');
    ++cnt[x];
  }
  sort(names, names + n);
  sort(surnames, surnames + n);
  for (int i = 0; i < n; ++i) {
    string s = names[i];
    int g = -1;
    int Z = (int)(s[0] - 'A');
    if (g == -1) {
      for (int j = 0; j < n; ++j) {
        if (was[j]) continue;
        string y = surnames[j];
        if (s[0] == y[0]) {
          g = j;
          break;
        }
        if (cnt[Z] > -1) continue;
        int X = (int)(y[0] - 'A');
        if (cnt[X] < 1) continue;
        --cnt[X];
        ++cnt[Z];
        g = j;
        break;
      }
    }
    was[g] = 1;
    cout << names[i] << " " << surnames[g];
    if (i + 1 < n) cout << ", ";
  }
  return 0;
}
