#include <bits/stdc++.h>
using namespace std;
struct str {
  char ch[101];
  int len;
  bool operator<(const str& b) const {
    int lim = min(len, b.len);
    for (int i = 0; i < lim; ++i)
      if (ch[i] != b.ch[i]) return ch[i] < b.ch[i];
    return len < b.len;
  }
} str1[105], str2[105];
int n, st1[27], st2[27], cur1[27], cur2[27], mx1[27], mx2[27];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%s", str1[i].ch), str1[i].len = strlen(str1[i].ch);
  for (int i = 1; i <= n; ++i)
    scanf("%s", str2[i].ch), str2[i].len = strlen(str2[i].ch);
  sort(str1 + 1, str1 + 1 + n);
  sort(str2 + 1, str2 + 1 + n);
  char a = 'A', b = 'A';
  for (int i = 1; i <= n; ++i) {
    while (str1[i].ch[0] != a) {
      a++;
      st1[a - 'A'] = i;
    }
    if (!st1[a - 'A']) st1[a - 'A'] = i;
    mx1[a - 'A']++;
    while (str2[i].ch[0] != b) {
      b++;
      st2[b - 'A'] = i;
    }
    if (!st2[b - 'A']) st2[b - 'A'] = i;
    mx2[b - 'A']++;
  }
  for (++a; a < 'Z'; ++a) st1[a - 'A'] = n;
  for (++b; b < 'Z'; ++b) st2[b - 'A'] = n;
  for (int i = 1; i <= n; ++i) {
    int cap = str1[i].ch[0] - 'A';
    if (mx2[cap] - cur2[cap] < mx1[cap] - cur1[cap]) {
      for (int j = 0; j <= 25; ++j) {
        if (mx2[j] - cur2[j] > 0 &&
            (mx2[j] - cur2[j] > mx1[j] - cur1[j] || j == cap)) {
          cur1[cap]++;
          cur2[j]++;
          cout << str1[i].ch << " " << str2[st2[j] + cur2[j] - 1].ch;
          break;
        }
      }
    } else if (cur2[cap] <= mx2[cap] - 1) {
      cur1[cap]++;
      cur2[cap]++;
      cout << str1[i].ch << " " << str2[st2[cap] + cur2[cap] - 1].ch;
    } else
      for (int j = 0; j <= 25; ++j) {
        if (mx2[j] - cur2[j] > 0 && mx2[j] - cur2[j] > mx1[j] - cur1[j]) {
          cur1[cap]++;
          cur2[j]++;
          cout << str1[i].ch << " " << str2[st2[j] + cur2[j] - 1].ch;
          break;
        }
      }
    if (i != n) printf(", ");
  }
}
