#include <bits/stdc++.h>
using namespace std;
struct str_list {
  vector<string> a;
  void sort_() { sort(a.begin(), a.end()); }
  int get_head_num(char c) {
    int ret = 0;
    for (int i = 0; i < a.size(); i++) {
      if (a[i][0] == c) ret++;
    }
    return ret;
  }
  void add(string str) { a.push_back(str); }
  void erase(int i) { a.erase(a.begin() + i); }
  void print() {
    for (int i = 0; i < a.size(); i++) cout << a[i] << endl;
  }
  int size() { return a.size(); }
  string operator[](int i) { return a[i]; }
} name, surname, name_rem, surname_rem, ans;
int N;
void init() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    string str;
    cin >> str;
    name.add(str);
  }
  for (int i = 0; i < N; i++) {
    string str;
    cin >> str;
    surname.add(str);
  }
  name.sort_();
  surname.sort_();
}
inline void cl_name() {
  name_rem.add(name[0]);
  name.erase(0);
}
inline void cl_surname() {
  surname_rem.add(surname[0]);
  surname.erase(0);
}
inline void clear_name(int num) {
  for (int i = 0; i < num; i++) {
    cl_name();
  }
}
inline void clear_surname(int num) {
  for (int i = 0; i < num; i++) {
    cl_surname();
  }
}
string make_ans(string str1, string str2) { return str1 + " " + str2; }
void work() {
  for (char x = 'A'; x <= 'Z'; x++) {
    int an = name.get_head_num(x);
    int bn = surname.get_head_num(x);
    while (an && name[0][0] != x) cl_name();
    while (bn && surname[0][0] != x) cl_surname();
    if (an == 0 || bn == 0) {
      clear_name(an);
      clear_surname(bn);
      continue;
    }
    int cha = int(name_rem.size() - surname_rem.size());
    int cn = 0;
    if (bn > an && cha > 0)
      cn = min((bn - an), cha), clear_surname(cn);
    else if (bn < an && cha < 0)
      cn = min((an - bn), abs(cha)), clear_name(cn);
    for (int i = 0; i < min(an, bn); i++) {
      ans.add(make_ans(name[0], surname[0]));
      name.erase(0);
      surname.erase(0);
    }
  }
  clear_name(name.size());
  clear_surname(surname.size());
  name_rem.sort_();
  surname_rem.sort_();
  for (int i = 0; i < name_rem.size(); i++) {
    ans.add(make_ans(name_rem[i], surname_rem[i]));
  }
  ans.sort_();
  for (int i = 0; i < N - 1; i++) cout << ans[i] << ", ";
  cout << ans[N - 1] << endl;
}
int main() {
  init();
  work();
  return 0;
}
