#include <bits/stdc++.h>
using namespace std;
const int MaxN = 102, NA = -1, MaxC = 0x3F3F3F3F;
string x[MaxN], y[MaxN], z[MaxN];
bool a[MaxN][MaxN];
bool b[MaxN];
int c[MaxN];
int d[MaxN];
int k, n;
bool bipart(int v) {
  assert(v >= 0 && v < n);
  if (b[v] || v <= k) return false;
  b[v] = true;
  int u;
  for (u = 0; u < n; u++)
    if (a[v][u])
      if (c[u] == NA || bipart(c[u])) {
        c[u] = v;
        d[v] = u;
        return true;
      }
  return false;
}
int main(void) {
  int i, j;
  while (scanf(" %d", &n) != EOF) {
    for (i = 0; i < n; i++) {
      char buf[MaxN];
      scanf(" %s", buf);
      x[i] = buf;
    }
    for (i = 0; i < n; i++) {
      char buf[MaxN];
      scanf(" %s", buf);
      y[i] = buf;
    }
    sort(x, x + n);
    sort(y, y + n);
    for (i = 0; i < n; i++)
      for (j = 0; j < n; j++) a[i][j] = (x[i][0] == y[j][0]);
    memset(c, NA, sizeof(c));
    memset(d, NA, sizeof(d));
    k = NA;
    for (i = 0; i < n; i++) {
      memset(b, 0, sizeof(b));
      bipart(i);
    }
    for (k = 0; k < n; k++) {
      if (d[k] == NA) {
        for (j = 0; j < n; j++) {
          if (c[j] >= 0 && c[j] < k) continue;
          memset(b, 0, sizeof(b));
          if (c[j] == NA || bipart(c[j])) {
            d[k] = j;
            c[j] = k;
            break;
          }
        }
      } else {
        for (j = 0; j < n; j++) {
          if (d[k] == j) break;
          if (c[j] < k) continue;
          memset(b, 0, sizeof(b));
          c[d[k]] = NA;
          if (bipart(c[j])) {
            d[k] = j;
            c[j] = k;
            break;
          }
          c[d[k]] = k;
        }
      }
    }
    for (i = 0; i < n; i++) z[i] = y[d[i]];
    for (i = 0; i < n; i++) {
      for (j = i + 1; j < n; j++)
        if (x[i][0] != x[j][0]) break;
      sort(z + i, z + j);
    }
    for (i = 0; i < n; i++)
      printf("%s %s%s", x[i].c_str(), z[i].c_str(), i + 1 < n ? ", " : "\n");
  }
  return 0;
}
