#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;
string names[111];
string surnames[111];
bool vis1[111];
bool vis2[111];
int go[111];
vector<string> res;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) cin >> names[i];
  for (int i = 0; i < n; i++) cin >> surnames[i];
  sort(names, names + n);
  sort(surnames, surnames + n);
  memset(go, -1, sizeof(go));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (!vis2[j] && names[i][0] == surnames[j][0]) {
        vis2[j] = true;
        vis1[i] = true;
        go[i] = j;
        break;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (!vis1[i]) {
      for (int j = 0; j < n; j++) {
        if (!vis2[j]) {
          vis1[i] = true;
          vis2[j] = true;
          go[i] = j;
          break;
        }
      }
    }
  }
  int xxx = 0;
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        string var1 = names[i] + " " + surnames[go[i]];
        string var2 = names[i] + " " + surnames[go[j]];
        if ((names[i][0] == surnames[go[i]][0]) +
                (names[j][0] == surnames[go[j]][0]) ==
            (names[i][0] == surnames[go[j]][0]) +
                (names[j][0] == surnames[go[i]][0])) {
          if (var2 < var1) swap(go[i], go[j]);
          xxx++;
          continue;
        }
      }
    }
    if (xxx == 0) break;
  }
  for (int i = 0; i < n; i++) {
    res.push_back(names[i] + " " + surnames[go[i]]);
  }
  for (int i = 0; i < n; i++) {
    cout << res[i];
    if (i != n - 1) cout << ", ";
  }
  return 0;
}
