#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:300000000")
const long double eps = 1e-20;
const long double pi = acos(-1.0);
const long long inf = 1000 * 1000 * 1000 * 1000 * 1000 * 1000;
const long long base = 1000 * 1000 * 1000 + 7;
using namespace std;
int get(char ch) { return (int)(ch - 'A' + 1); }
vector<string> name, lname;
string s;
int k1[40], k2[40], k3[40], n, was[11111], pos, pos1, pos2;
int main() {
  ios_base ::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < (n); i++) {
    cin >> s;
    name.push_back(s);
  }
  for (int i = 0; i < (n); i++) {
    cin >> s;
    lname.push_back(s);
  }
  sort(name.begin(), name.end());
  sort(lname.begin(), lname.end());
  for (int i = 0; i < (name.size()); i++) k1[get(name[i][0])]++;
  for (int i = 0; i < (lname.size()); i++) k2[get(lname[i][0])]++;
  for (int i = 0; i < (30); i++) k3[i] = min(k1[i], k2[i]);
  for (int i = 0; i < (name.size()); i++) {
    pos1 = -1;
    pos2 = -1;
    for (int j = (lname.size()) - 1; j >= 0; j--)
      if (was[j] == 0 && name[i][0] == lname[j][0]) pos1 = j;
    for (int j = (lname.size()) - 1; j >= 0; j--)
      if (was[j] == 0 && name[i][0] != lname[j][0] &&
          k3[get(lname[j][0])] < k2[get(lname[j][0])])
        pos2 = j;
    if (pos2 == -1)
      pos = pos1;
    else if (pos1 == -1)
      pos = pos2;
    else {
      if (k3[get(name[i][0])] < k1[get(name[i][0])])
        pos = min(pos1, pos2);
      else
        pos = pos1;
    }
    if (pos == -1)
      for (int j = (n)-1; j >= 0; j--)
        if (was[j] == 0) pos = j;
    k1[get(name[i][0])]--;
    k2[get(lname[pos][0])]--;
    if (get(name[i][0]) == get(lname[pos][0])) k3[get(lname[pos][0])]--;
    cout << name[i] << " " << lname[pos];
    was[pos] = 1;
    if (i != n - 1) cout << ", ";
  }
  return 0;
}
