#include <bits/stdc++.h>
using namespace std;
vector<string> a[33], b[33];
string s;
int n, p[33];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) cin >> s, a[s[0] - 65].push_back(s);
  for (int i = 0; i < n; i++) cin >> s, b[s[0] - 65].push_back(s);
  for (int i = 0; i < 26; i++)
    p[i] = 0, sort(a[i].begin(), a[i].end()), sort(b[i].begin(), b[i].end());
  for (int i = 0; i < 26; i++)
    for (int j = 0; j < a[i].size(); j++) {
      cout << a[i][j] << " ";
      int flag = 0;
      if (a[i].size() - j > b[i].size())
        for (int k = 0; k < i && !flag; k++)
          if (p[k] < b[k].size()) cout << b[k][p[k]++], flag = 1;
      if (!flag)
        if (p[i] < b[i].size())
          cout << b[i][p[i]++];
        else
          for (int k = i + 1; k < 26 && !flag; k++)
            if (p[k] < b[k].size() && b[k].size() - p[k] > a[k].size())
              cout << b[k][p[k]++], flag = 1;
      if (--n)
        cout << ", ";
      else
        cout << endl;
    }
  return 0;
}
