#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int strToInt(string& a) {
  stringstream x(a);
  int b;
  x >> b;
  return b;
}
void readI(int& a) { cin >> a; }
void readI(int& a, int& b) { cin >> a >> b; }
void readI(int& a, int& b, int& c) { cin >> a >> b >> c; }
vector<int> readVI(int n) {
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  return a;
}
vector<vector<int> > readVVI(int n, int m) {
  vector<vector<int> > a(n, vector<int>(m));
  for (int i = 0; i < n; i++) a[i] = readVI(m);
  return a;
}
vector<long long> readVLL(long long n) {
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  return a;
}
vector<vector<long long> > readVVLL(long long n, long long m) {
  vector<vector<long long> > a(n, vector<long long>(m));
  for (int i = 0; i < n; i++) a[i] = readVLL(m);
  return a;
}
void print(vector<int>& a) {
  for (auto el : a) {
    cout << el << ' ';
  }
  cout << '\n';
}
void print(vector<int>& a, int n) {
  int cnt = 0;
  for (auto el : a) {
    if (cnt++ == n) break;
    cout << el << ' ';
  }
  cout << '\n';
}
const int MOD = 1e9 + 7;
const int INF = INT_MAX;
const long long INFF = INT64_MAX;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int moveX[] = {-1, 0, 1, 0};
const int moveY[] = {0, 1, 0, -1};
void go() {
  int n;
  cin >> n;
  vector<string> names(n), surnames(n);
  for (int i = 0; i < n; i++) cin >> names[i];
  for (int i = 0; i < n; i++) cin >> surnames[i];
  sort(names.begin(), names.end());
  sort(surnames.begin(), surnames.end());
  vector<vector<string> > names1(30), surnames1(30);
  for (auto el : names) names1[el[0] - 'A'].push_back(el);
  for (auto el : surnames) surnames1[el[0] - 'A'].push_back(el);
  vector<int> pt(30, 0), pt1(30, 0);
  vector<pair<string, string> > ans;
  for (int i = 0; i < 30; i++) {
    while (pt[i] != names1[i].size()) {
      pair<string, string> cur;
      cur.first = names1[i][pt[i]++];
      bool done = 0;
      for (int j = 0; j < 30; j++) {
        if (i == j && surnames1[i].size() - pt1[i] > 0) break;
        if (names1[j].size() - pt[j] < surnames1[j].size() - pt1[j] &&
            names1[i].size() - pt[i] + 1 > surnames1[i].size() - pt1[i]) {
          cur.second = surnames1[j][pt1[j]++];
          done = 1;
          break;
        }
      }
      if (!done) {
        cur.second = surnames1[i][pt1[i]++];
      }
      ans.push_back(cur);
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i].first << ' ' << ans[i].second;
    if (i + 1 != n) cout << ", ";
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T = 1;
  while (T--) go();
  return 0;
}
