#include <bits/stdc++.h>
using namespace std;
vector<string> a[26], b[26];
vector<string> aa[26], bb[26];
template <typename _Tp>
inline void sort(vector<_Tp>& v) {
  sort(v.begin(), v.end());
}
void solve() {
  for (int i = 0; i < 26; ++i) {
    sort(a[i]);
    sort(b[i]);
  }
  priority_queue<string, vector<string>, greater<string> > qa, qb;
  priority_queue<pair<string, string>, vector<pair<string, string> >,
                 greater<pair<string, string> > >
      ans;
  for (int i = 0; i < 26; ++i) {
    if (a[i].size() == b[i].size()) {
      for (int j = 0; j < a[i].size(); ++j) {
        ans.push(make_pair(a[i][j], b[i][j]));
      }
    } else {
      if (a[i].size() > b[i].size()) {
        int can = a[i].size() - b[i].size();
        if (can > qb.size()) can = qb.size();
        int j = 0;
        for (; j < can; ++j) {
          ans.push(make_pair(a[i][j], qb.top()));
          qb.pop();
        }
        for (; j < a[i].size(); ++j) {
          if (j - can < b[i].size())
            ans.push(make_pair(a[i][j], b[i][j - can]));
          else
            qa.push(a[i][j]);
        }
      } else {
        int can = b[i].size() - a[i].size();
        if (can > qa.size()) can = qa.size();
        int j = 0;
        for (; j < can; ++j) {
          ans.push(make_pair(qa.top(), b[i][j]));
          qa.pop();
        }
        for (; j < b[i].size(); ++j) {
          if (j - can < a[i].size())
            ans.push(make_pair(a[i][j - can], b[i][j]));
          else
            qb.push(b[i][j]);
        }
      }
    }
  }
  assert(qa.size() == qb.size());
  while (!qa.empty() && !qb.empty()) {
    ans.push(make_pair(qa.top(), qb.top()));
    qa.pop();
    qb.pop();
  }
  bool first = true;
  while (!ans.empty()) {
    if (!first) cout << ", ";
    first = false;
    cout << ans.top().first << ' ' << ans.top().second;
    ans.pop();
  }
  cout << endl;
}
char str[65535];
int main(int argc, char** argv) {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%s", str);
    int x = str[0] - 'A';
    assert(x >= 0 && x < 26);
    a[x].push_back(str);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%s", str);
    int x = str[0] - 'A';
    assert(x >= 0 && x < 26);
    b[x].push_back(str);
  }
  solve();
  return EXIT_SUCCESS;
}
