#include <bits/stdc++.h>
using namespace std;
const int MAXN = 105;
string name[MAXN], surname[MAXN];
bool u[MAXN];
int n;
int x1[30], x2[30];
int Getn() {
  int res = 0;
  for (int i = 0; i < 26; i++) res += min(x1[i], x2[i]);
  return res;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> name[i];
  for (int i = 1; i <= n; i++) cin >> surname[i];
  sort(name + 1, name + n + 1);
  sort(surname + 1, surname + n + 1);
  for (int i = 1; i <= n; i++) x1[name[i][0] - 'A']++;
  for (int i = 1; i <= n; i++) x2[surname[i][0] - 'A']++;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++)
      if (!u[j]) {
        int c = Getn();
        x1[name[i][0] - 'A']--;
        x2[surname[j][0] - 'A']--;
        if (Getn() != c - (name[i][0] == surname[j][0])) {
          x1[name[i][0] - 'A']++;
          x2[surname[j][0] - 'A']++;
          continue;
        }
        u[j] = true;
        cout << name[i] << ' ' << surname[j];
        if (i != n)
          cout << ", ";
        else
          cout << endl;
        break;
      }
  }
  return 0;
}
