#include <bits/stdc++.h>
using namespace std;
int m, n, j, k, l, i, o, p, __t;
char ch;
void read(int &a) {
  for (ch = getchar(); (ch < '0' || ch > '9') && (ch != '-'); ch = getchar())
    ;
  if (ch == '-')
    a = 0, __t = -1;
  else
    a = ch - '0', __t = 1;
  for (ch = getchar(); ch >= '0' && ch <= '9'; ch = getchar())
    a = a * 10 + ch - '0';
  a *= __t;
}
string first[1000], second[1000];
int F[27], S[27];
bool exist[1000];
int main() {
  cin >> m;
  for (int i = 1; i <= m; i++) cin >> first[i], F[first[i][0] - 'A']++;
  for (int i = 1; i <= m; i++) cin >> second[i], S[second[i][0] - 'A']++;
  sort(first + 1, first + 1 + m);
  sort(second + 1, second + 1 + m);
  for (int i = 1; i <= m; i++) {
    bool could = 0;
    if (F[first[i][0] - 'A'] > S[first[i][0] - 'A']) {
      for (int j = 1; j <= m; j++)
        if (!exist[j] && (second[j][0] == first[i][0] ||
                          (S[second[j][0] - 'A'] > F[second[j][0] - 'A']))) {
          cout << first[i] << ' ' << second[j];
          if (i == m)
            cout << endl;
          else
            cout << ", ";
          exist[j] = 1;
          S[second[j][0] - 'A']--;
          could = 1;
          break;
        }
    } else {
      for (int j = 1; j <= m; j++)
        if (second[j][0] == first[i][0] && !exist[j]) {
          cout << first[i] << ' ' << second[j];
          if (i == m)
            cout << endl;
          else
            cout << ", ";
          exist[j] = 1;
          S[second[j][0] - 'A']--;
          could = 1;
          break;
        }
    }
    F[first[i][0] - 'A']--;
  }
}
