#include <bits/stdc++.h>
using namespace std;
string s1[105], s2[105], s3[105], s4[105];
struct ab {
  string a;
  string b;
} ans[105];
int an, a3, a4;
int cmp(const void *x, const void *y) {
  ab xx = *(ab *)x;
  ab yy = *(ab *)y;
  if (xx.a > yy.a) return 1;
  if (xx.a < yy.a) return -1;
  if (xx.b > yy.b) return 1;
  if (xx.b < yy.b) return -1;
  return 0;
}
int main() {
  int i, j, n;
  while (scanf("%d", &n) != EOF) {
    an = 0;
    a3 = a4 = 0;
    for (i = 0; i < n; i++) cin >> s1[i];
    sort(s1, s1 + n);
    for (i = 0; i < n; i++) cin >> s2[i];
    sort(s2, s2 + n);
    for (i = 0, j = 0; i < n && j < n;) {
      if (s1[i][0] == s2[j][0]) {
        ans[an].a = s1[i];
        ans[an].b = s2[j];
        an++;
        i++;
        j++;
      } else {
        if (s1[i][0] < s2[j][0]) {
          s3[a3++] = s1[i];
          i++;
        } else {
          s4[a4++] = s2[j];
          j++;
        }
      }
    }
    while (i < n) {
      s3[a3++] = s1[i++];
    }
    while (j < n) {
      s4[a4++] = s2[j++];
    }
    for (i = 0, j = 0; i < a3 && j < a4; i++, j++) {
      ans[an].a = s3[i];
      ans[an].b = s4[j];
      an++;
    }
    qsort(ans, an, sizeof(ans[0]), cmp);
    for (i = 0; i < an; i++) {
      for (j = i + 1; j < an; j++) {
        if (ans[i].b[0] == ans[j].a[0] && ans[j].a[0] == ans[j].b[0]) {
          if (ans[j].b < ans[i].b) {
            string tt = ans[i].b;
            ans[i].b = ans[j].b;
            ans[j].b = tt;
          }
        }
        if (ans[i].a[0] == ans[i].b[0] && ans[i].a[0] == ans[j].a[0]) {
          if (ans[i].b > ans[j].b) {
            string tt = ans[i].b;
            ans[i].b = ans[j].b;
            ans[j].b = tt;
          }
        }
      }
    }
    for (i = 0; i < an - 1; i++) {
      cout << ans[i].a << " " << ans[i].b << ", ";
    }
    cout << ans[i].a << " " << ans[i].b << endl;
  }
}
