#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007, dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
const double eps = 1e-8;
void read(int &k) {
  k = 0;
  char x = getchar();
  while (x < '0' || x > '9') x = getchar();
  while (x >= '0' && x <= '9') {
    k = k * 10 - 48 + x;
    x = getchar();
  }
}
string s0[110], s1[110];
int A[30], B[30], n, cho[110];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> s0[i];
  for (int i = 0; i < n; i++) cin >> s1[i];
  sort(s0, s0 + n);
  sort(s1, s1 + n);
  for (int i = 0; i < n; i++) A[s0[i][0] - 65]++;
  for (int i = 0; i < n; i++) B[s1[i][0] - 65]++;
  for (int i = 0; i < n; i++) {
    if (A[s0[i][0] - 65] > B[s0[i][0] - 65]) {
      for (int j = 0; j < n; j++)
        if (!cho[j] &&
            (B[s1[j][0] - 65] > A[s1[j][0] - 65] || s1[j][0] == s0[i][0])) {
          cho[j] = 1;
          A[s0[i][0] - 65]--;
          B[s1[j][0] - 65]--;
          cout << s0[i] << ' ' << s1[j];
          if (i < n - 1) cout << ", ";
          break;
        }
    } else {
      for (int j = 0; j < n; j++)
        if (!cho[j] && s1[j][0] == s0[i][0]) {
          cho[j] = 1;
          A[s0[i][0] - 65]--;
          B[s0[i][0] - 65]--;
          cout << s0[i] << ' ' << s1[j];
          if (i < n - 1) cout << ", ";
          break;
        }
    }
  }
  return 0;
}
