#include <bits/stdc++.h>
using namespace std;
vector<string> name;
vector<string> last;
int nametake[100];
int lasttake[100];
void link(int left[100], int left_min, int left_max, int right[100],
          int right_min, int right_max) {
  if (0)
    cout << "left_min"
         << " " << left_min << endl;
  ;
  if (0)
    cout << "left_max"
         << " " << left_max << endl;
  ;
  if (0)
    cout << "right_min"
         << " " << right_min << endl;
  ;
  if (0)
    cout << "right_max"
         << " " << right_max << endl;
  ;
  int right_start;
  if (right_min < left_min && right_max < left_max) {
    right_start = right_max - (left_max - left_min);
  } else if (right_min > left_min && right_max > left_max) {
    right_start = right_min;
  } else {
    right_start = left_min;
  }
  for (int left_i = left_min, right_i = right_start; left_i <= left_max;
       left_i += 1, right_i += 1) {
    left[left_i] = right_i;
    right[right_i] = left_i;
  }
}
int main() {
  for (int k = 0; k < 1; k++) {
    int n;
    cin >> n;
    string s;
    for (int i = 0; i < n; ++i) {
      cin >> s;
      name.push_back(s);
      nametake[i] = -1;
    }
    for (int i = 0; i < n; ++i) {
      cin >> s;
      last.push_back(s);
      lasttake[i] = -1;
    }
    sort(name.begin(), name.end());
    sort(last.begin(), last.end());
    for (char ch = 'A'; ch <= 'Z'; ch += 1) {
      int name_min, name_max;
      for (name_min = 0; name_min < n && name[name_min][0] != ch; name_min += 1)
        ;
      if (name_min == n) continue;
      for (name_max = n - 1; name_max >= 0 && name[name_max][0] != ch;
           name_max -= 1)
        ;
      int last_min, last_max;
      for (last_min = 0; last_min < n && last[last_min][0] != ch; last_min += 1)
        ;
      if (last_min == n) continue;
      for (last_max = n - 1; last_max >= 0 && last[last_max][0] != ch;
           last_max -= 1)
        ;
      if (name_max - name_min < last_max - last_min)
        link(nametake, name_min, name_max, lasttake, last_min, last_max);
      else
        link(lasttake, last_min, last_max, nametake, name_min, name_max);
    }
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (lasttake[j] == -1 && nametake[i] == -1) {
          nametake[i] = j;
          lasttake[j] = i;
        }
      }
      if (0)
        cout << "nametake[i]"
             << " " << nametake[i] << endl;
      ;
      if (0)
        cout << "lasttake[i]"
             << " " << lasttake[i] << endl;
      ;
    }
    for (int i = 0; i < n; ++i) {
      if (i) cout << ", ";
      cout << name[i] << " " << last[nametake[i]];
    }
    cout << endl;
  }
  return 0;
}
