#include <bits/stdc++.h>
using namespace std;
string a[3010];
string b[3010];
int from[3010], to[3010];
int n;
int sampleIndex = -1;
vector<int> z_function(string s) {
  int n = (int)s.length();
  vector<int> z(n);
  for (int i = 1, l = 0, r = 0; i < n; ++i) {
    if (i <= r) z[i] = min(r - i + 1, z[i - l]);
    while (i + z[i] < n && s[z[i]] == s[i + z[i]]) ++z[i];
    if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;
  }
  return z;
}
bool possible(int x, bool left) {
  if ((left && from[sampleIndex] - x < 0) ||
      (!left && to[sampleIndex] + x >= a[sampleIndex].length())) {
    return false;
  }
  char sampleA, sampleB;
  if (left) {
    sampleA = a[sampleIndex][from[sampleIndex] - x];
    sampleB = b[sampleIndex][from[sampleIndex] - x];
  } else {
    sampleA = a[sampleIndex][to[sampleIndex] + x];
    sampleB = b[sampleIndex][to[sampleIndex] + x];
  }
  for (int i = 0; i < n; ++i) {
    if (from[i] == 1000000) {
      continue;
    }
    if (left) {
      if (from[i] - x < 0) {
        return false;
      } else if (a[i][from[i] - x] != sampleA || b[i][from[i] - x] != sampleB) {
        return false;
      }
    } else {
      if (to[i] + x >= a[i].length()) {
        return false;
      } else if (a[i][to[i] + x] != sampleA || b[i][to[i] + x] != sampleB) {
        return false;
      }
    }
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int j = 0; j < n; ++j) {
    cin >> b[j];
    if (a[j] != b[j]) {
      sampleIndex = j;
    }
  }
  for (int i = 0; i < n; ++i) {
    from[i] = 1000000;
    for (int j = 0; j < a[i].length(); ++j) {
      if (a[i][j] != b[i][j]) {
        if (from[i] == 1000000) {
          from[i] = j;
        }
        to[i] = j;
      }
    }
  }
  string aStr = a[sampleIndex].substr(from[sampleIndex],
                                      to[sampleIndex] - from[sampleIndex] + 1);
  string bStr = b[sampleIndex].substr(from[sampleIndex],
                                      to[sampleIndex] - from[sampleIndex] + 1);
  for (int i = 0; i < n; ++i) {
    if (from[i] == 1000000) {
      continue;
    }
    string curAStr = a[i].substr(from[i], to[i] - from[i] + 1);
    string curBStr = b[i].substr(from[i], to[i] - from[i] + 1);
    if (curAStr != aStr || curBStr != bStr) {
      cout << "NO";
      return 0;
    }
  }
  int toLeft = 0;
  int toRight = 0;
  while (possible(toLeft, true)) {
    toLeft++;
  }
  toLeft--;
  while (possible(toRight, false)) {
    toRight++;
  }
  toRight--;
  for (int i = 0; i < n; ++i) {
    from[i] -= toLeft;
    to[i] += toRight;
  }
  aStr = a[sampleIndex].substr(from[sampleIndex],
                               to[sampleIndex] - from[sampleIndex] + 1);
  bStr = b[sampleIndex].substr(from[sampleIndex],
                               to[sampleIndex] - from[sampleIndex] + 1);
  for (int i = 0; i < n; ++i) {
    int cutLen = to[sampleIndex] - from[sampleIndex] + 1;
    string newA = aStr + a[i];
    string newB = bStr + b[i];
    vector<int> pref_a = z_function(newA);
    vector<int> pref_b = z_function(newB);
    for (int j = 0; j < pref_a.size(); ++j) {
      if (from[i] == 1000000) {
        if (pref_a[j] >= cutLen && j >= cutLen) {
          cout << "NO";
          return 0;
        }
      } else if (pref_a[j] >= cutLen && j < from[i] + cutLen && j >= cutLen) {
        cout << "NO";
        return 0;
      }
    }
  }
  cout << "YES" << endl;
  cout << aStr << endl;
  cout << bStr << endl;
}
