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