#include <bits/stdc++.h>
using namespace std;
template <class T>
using VV = vector<vector<T>>;
template <class T>
inline T SMIN(T &a, const T b) {
  return a = (a > b) ? b : a;
}
template <class T>
inline T SMAX(T &a, const T b) {
  return a = (a < b) ? b : a;
}
template <class Iter>
void dumpc(Iter begin, Iter end) {
  if (false) {
    for (; begin != end; ++begin) {
      cerr << *begin << ',';
    }
    cerr << endl;
  }
}
const int MAX_N = 3010 + 1;
string W1[MAX_N], W2[MAX_N];
int N;
namespace RollingHash {
template <int MOD>
struct ModInt {
  unsigned int val;
  ModInt() : val(0) {}
  ModInt(int v) { norm(v % MOD); }
  ModInt(long long v) { norm(v % MOD); }
  ModInt &norm(long long v) {
    v = v < 0 ? v % MOD + MOD : v;
    v = v >= MOD ? v - MOD : v;
    val = (unsigned int)v;
    return *this;
  }
  explicit operator bool() const { return val != 0; }
  ModInt operator-() const { return ModInt(0) - *this; }
  ModInt &operator+=(ModInt that) { return norm((long long)val + that.val); }
  ModInt &operator-=(ModInt that) { return norm((long long)val - that.val); }
  ModInt &operator*=(ModInt that) {
    val = (unsigned long long)val * that.val % MOD;
    return *this;
  }
  ModInt &operator/=(ModInt that) { return *this *= that.inv(); }
  ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
  ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
  ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
  ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
  ModInt pow(long long n) const {
    ModInt x = *this, res = 1;
    while (n > 0) {
      if (n & 1) res *= x;
      x *= x, n >>= 1;
    }
    return res;
  }
  ModInt inv() const { return (*this).pow(MOD - 2); }
  bool operator==(ModInt that) const { return val == that.val; }
  bool operator!=(ModInt that) const { return val != that.val; }
};
const int MOD0 = 1e9 + 7, MOD1 = 1e9 + 9;
using M0 = ModInt<MOD0>;
using M1 = ModInt<MOD1>;
M0 p0 = rand() % MOD0, pinv0 = p0.inv();
M1 p1 = rand() % MOD1, pinv1 = p1.inv();
vector<M0> P0{1}, PINV0{1};
vector<M1> P1{1}, PINV1{1};
struct H {
  vector<pair<M0, M1>> hcum;
  string str;
  H(string s) : str(s) {
    int N = (int)s.size();
    while ((int)P0.size() <= N) {
      P0.push_back(P0.back() * p0);
      PINV0.push_back(PINV0.back() * pinv0);
      P1.push_back(P1.back() * p1);
      PINV1.push_back(PINV1.back() * pinv1);
    }
    hcum.resize(N + 1);
    hcum[0] = {M0(0), M1(0)};
    for (int i = 0; i < N; ++i) {
      hcum[i + 1] = {hcum[i].first + M0(s[i]) * P0[i],
                     hcum[i].second + M1(s[i]) * P1[i]};
    }
  }
  pair<M0, M1> hash(int r) { return {hcum[r].first, hcum[r].second}; }
  pair<M0, M1> hash(int l, int r) {
    return {(hcum[r].first - hcum[l].first) * PINV0[l],
            (hcum[r].second - hcum[l].second) * PINV1[l]};
  }
};
vector<int> match(H &s, H &p) {
  int N = s.str.size(), M = p.str.size();
  auto pp = p.hash(0, M);
  vector<int> res;
  for (int i = 0; i <= N - M; ++i)
    if (s.hash(i, i + M) == pp) res.push_back(i);
  return res;
}
};  // namespace RollingHash
struct RollingHash2 {
  static const long long mo0 = 1000000021, mo1 = 1000000009;
  static long long mul0, mul1;
  static const long long add0 = 1000010007, add1 = 1003333331;
  static vector<long long> pmo[2];
  string s;
  int l;
  vector<long long> hash_[2];
  void init(string s) {
    this->s = s;
    l = s.size();
    hash_[0] = hash_[1] = vector<long long>(1, 0);
    if (!mul0)
      mul0 = 10009 + (((long long)&mul0) >> 5) % 259,
      mul1 = 10007 + (((long long)&mul1) >> 5) % 257;
    if (pmo[0].empty()) pmo[0].push_back(1), pmo[1].push_back(1);
    for (int i = 0; i < (l); ++i)
      hash_[0].push_back((hash_[0].back() * mul0 + add0 + s[i]) % mo0);
    for (int i = 0; i < (l); ++i)
      hash_[1].push_back((hash_[1].back() * mul1 + add1 + s[i]) % mo1);
  }
  pair<long long, long long> hash(int l, int r) {
    if (l > r) return make_pair(0, 0);
    while (pmo[0].size() < r + 2)
      pmo[0].push_back(pmo[0].back() * mul0 % mo0),
          pmo[1].push_back(pmo[1].back() * mul1 % mo1);
    return make_pair(
        (hash_[0][r + 1] + (mo0 - hash_[0][l] * pmo[0][r + 1 - l] % mo0)) % mo0,
        (hash_[1][r + 1] + (mo1 - hash_[1][l] * pmo[1][r + 1 - l] % mo1)) %
            mo1);
  }
  pair<long long, long long> hash(string s) {
    init(s);
    return hash(0, s.size() - 1);
  }
  static pair<long long, long long> concat(pair<long long, long long> L,
                                           pair<long long, long long> R,
                                           int RL) {
    while (pmo[0].size() < RL + 2)
      pmo[0].push_back(pmo[0].back() * mul0 % mo0),
          pmo[1].push_back(pmo[1].back() * mul1 % mo1);
    return make_pair((R.first + L.first * pmo[0][RL]) % mo0,
                     (R.second + L.second * pmo[1][RL]) % mo1);
  }
};
vector<long long> RollingHash2::pmo[2];
long long RollingHash2::mul0, RollingHash2::mul1;
vector<int> buildPrefixFunction(const string S) {
  int L = S.size();
  vector<int> pi(L + 1, -1);
  int j = -1;
  for (int i = 0; i < L; ++i) {
    while (j >= 0 && S[i] != S[j]) j = pi[j];
    pi[i + 1] = ++j;
  }
  return pi;
}
vector<int> doKMP(string s, string p) {
  vector<int> res;
  vector<int> pi = buildPrefixFunction(p);
  int j = 0, L = s.size(), M = p.size();
  for (int i = 0; i < L; ++i) {
    while (j >= 0 && s[i] != p[j]) j = pi[j];
    ++j;
    if (j >= M) {
      res.push_back(i - j + 1);
      j = pi[j];
    }
  }
  return res;
}
void end() {
  fprintf(stdout, "NO"), putchar('\n');
  ;
  exit(0);
}
pair<int, int> boundary2(string s, string t, int l, int r) {
  int resl = 0, resr = 0, M = int((s).size());
  int j = l - 1;
  for (; j >= 0; --j) {
    if (s[j] != t[j]) break;
  }
  resl = l - j - 1;
  assert(resl >= 0);
  j = r + 1;
  for (; j < M; ++j)
    if (s[j] != t[j]) break;
  resr = j - r - 1;
  assert(resr >= 0);
  return {resl, resr};
}
int si = -1, sp = -1;
pair<int, int> boundary1(string s, string t, int l, int r, string x) {
  int resl = 0, resr = 0, M = int((s).size());
  int j = l - 1;
  for (; j >= 0; --j) {
    int d = l - j;
    if (s[j] != t[j] || sp - d < 0 || s[j] != W1[si][sp - d]) break;
  }
  resl = l - j - 1;
  assert(resl >= 0);
  j = r + 1;
  for (; j < M; ++j) {
    int d = j - r;
    int jj = sp + int((x).size()) + d - 1;
    if (s[j] != t[j] || jj >= int((W1[si]).size()) || s[j] != W1[si][jj]) break;
  }
  resr = j - r - 1;
  assert(resr >= 0);
  return {resl, resr};
}
void solve_wrong() {
  string s = "", t = "";
  int lb, rb;
  for (int i = 0; i < (N); ++i) {
    int M = int((W1[i]).size());
    int l = 3010, r = -1;
    for (int j = 0; j < (M); ++j)
      if (W1[i][j] != W2[i][j]) SMIN(l, j), SMAX(r, j);
    if (r != -1) {
      if (s.empty()) {
        s = W1[i].substr(l, r - l + 1);
        t = W2[i].substr(l, r - l + 1);
        lb = l, rb = int((W1[i]).size()) - r - 1;
        sp = l, si = i;
      } else {
        if (r - l + 1 != int((s).size())) end();
        int L = int((s).size());
        for (int j = 0; j < (L); ++j) {
          if (W1[i][l + j] != s[j]) end();
          if (W2[i][l + j] != t[j]) end();
        }
        auto p = boundary1(W1[i], W2[i], l, r, s);
        SMIN(lb, p.first);
        SMIN(rb, p.second);
      }
    } else {
      vector<int> ps = doKMP(W1[i], s);
      if (ps.empty()) continue;
      int j = ps.front();
      auto p = boundary2(W1[i], W2[i], j, j + int((s).size()) - 1);
      if (p.first >= lb && p.second >= rb) end();
    }
  }
  if (s.empty()) {
    s += W1[0][0], t += W1[0][0];
  } else {
    if (false) {
      cerr << "s"
           << " = " << (s) << ", "
           << "t"
           << " = " << (t) << ", "
           << "lb"
           << " = " << (lb) << ", "
           << "rb"
           << " = " << (rb) << endl;
    };
    if (false) {
      cerr << "sp"
           << " = " << (sp) << ", "
           << "si"
           << " = " << (si) << ", "
           << "W1[si]"
           << " = " << (W1[si]) << ", "
           << "W2[si]"
           << " = " << (W2[si]) << endl;
    };
    s = W1[si].substr(sp - lb, lb + rb + int((s).size()));
    t = W2[si].substr(sp - lb, lb + rb + int((t).size()));
  }
  fprintf(stdout, "YES"), putchar('\n');
  ;
  fprintf(stdout, "%s", s.c_str()), putchar('\n');
  ;
  fprintf(stdout, "%s", t.c_str()), putchar('\n');
  ;
}
pair<int, int> boundary(string s, string t, int l, int r) {
  int resl = 0, resr = 0, M = int((s).size());
  string u = W1[si];
  int j = l - 1;
  for (; j >= 0; --j) {
    int d = l - j;
    if (sp - d < 0 || s[j] != u[sp - d]) break;
  }
  resl = l - j - 1;
  assert(resl >= 0);
  j = r + 1;
  for (; j < M; ++j) {
    int d = j - r;
    int jj = sp + r - l + d;
    if (jj >= int((u).size()) || s[j] != u[jj]) break;
  }
  resr = j - r - 1;
  assert(resr >= 0);
  return {resl, resr};
}
void solve() {
  string s = "", t = "", pre = "", post = "";
  int lb, rb;
  for (int i = 0; i < (N); ++i) {
    int M = int((W1[i]).size());
    if (false) {
      cerr << "i"
           << " = " << (i) << ", "
           << "M"
           << " = " << (M) << endl;
    };
    int l = 3010, r = -1;
    for (int j = 0; j < (M); ++j)
      if (W1[i][j] != W2[i][j]) SMIN(l, j), SMAX(r, j);
    if (r != -1) {
      string ss = W1[i].substr(l, r - l + 1);
      string tt = W2[i].substr(l, r - l + 1);
      string prepre = W1[i].substr(0, l);
      string postpost = W2[i].substr(r + 1);
      reverse((prepre).begin(), (prepre).end());
      if (s.empty()) {
        s = ss, t = tt, pre = prepre, post = postpost;
        lb = l, rb = int((W1[i]).size()) - r - 1;
        sp = l, si = i;
      } else {
        if (r - l + 1 != int((s).size())) end();
        int L = int((s).size());
        for (int j = 0; j < (L); ++j) {
          if (W1[i][l + j] != s[j]) end();
          if (W2[i][l + j] != t[j]) end();
        }
        auto p = boundary(W1[i], W2[i], l, r);
        SMIN(lb, p.first);
        SMIN(rb, p.second);
      }
    }
  }
  s = W1[si].substr(sp - lb, lb + rb + int((s).size()));
  t = W2[si].substr(sp - lb, lb + rb + int((t).size()));
  for (int i = 0; i < (N); ++i) {
    string x = W1[i], y = W2[i];
    vector<int> ps = doKMP(x, s);
    if (ps.empty()) continue;
    int j = ps.front();
    int M = int((x).size());
    assert(j + int((s).size()) <= M);
    for (int o = 0; o < (int((s).size())); ++o) {
      assert(x[j + o] == s[o]);
      x[j + o] = t[o];
    }
    if (x != y) end();
  }
  fprintf(stdout, "YES"), putchar('\n');
  ;
  fprintf(stdout, "%s", s.c_str()), putchar('\n');
  ;
  fprintf(stdout, "%s", t.c_str()), putchar('\n');
  ;
}
RollingHash2 rh[3030];
void solve_inspired_by_kmjp() {
  string s = "", t = "", pre = "", post = "";
  for (int i = 0; i < (N); ++i) {
    int M = int((W1[i]).size());
    int l = 3010, r = -1;
    for (int j = 0; j < (M); ++j)
      if (W1[i][j] != W2[i][j]) SMIN(l, j), SMAX(r, j);
    if (r != -1) {
      string ss = W1[i].substr(l, r - l + 1);
      string tt = W2[i].substr(l, r - l + 1);
      string prepre = W1[i].substr(0, l);
      string postpost = W2[i].substr(r + 1);
      reverse((prepre).begin(), (prepre).end());
      if (s.empty()) {
        s = ss, t = tt, pre = prepre, post = postpost;
      } else {
        if (ss != s || tt != t) {
          if (false) {
            cerr << "ss"
                 << " = " << (ss) << ", "
                 << "s"
                 << " = " << (s) << ", "
                 << "tt"
                 << " = " << (tt) << ", "
                 << "t"
                 << " = " << (t) << endl;
          };
          end();
        }
        for (int j = 0; j < (int((pre).size())); ++j)
          if (j >= int((prepre).size()) || prepre[j] != pre[j]) {
            pre.resize(j);
            break;
          }
        for (int j = 0; j < (int((post).size())); ++j)
          if (j >= int((postpost).size()) || postpost[j] != post[j]) {
            post.resize(j);
            break;
          }
      }
    }
  }
  if (false) {
    cerr << "s"
         << " = " << (s) << ", "
         << "t"
         << " = " << (t) << ", "
         << "pre"
         << " = " << (pre) << ", "
         << "post"
         << " = " << (post) << endl;
  };
  reverse((pre).begin(), (pre).end());
  s = pre + s + post;
  t = pre + t + post;
  auto ha = rh[N].hash(s);
  for (int i = 0; i < (N); ++i) {
    rh[i].init(W1[i]);
    string x = W1[i], y = W2[i];
    for (int j = 0; j + s.size() <= x.size(); j++) {
      if (rh[i].hash(j, j + s.size() - 1) == ha) {
        x = x.substr(0, j) + t + x.substr(s.size() + j);
        break;
      }
    }
    if (x != y) end();
  }
  fprintf(stdout, "YES"), putchar('\n');
  ;
  fprintf(stdout, "%s", s.c_str()), putchar('\n');
  ;
  fprintf(stdout, "%s", t.c_str()), putchar('\n');
  ;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  scanf("%d", &N);
  if (false) {
    cerr << "N"
         << " = " << (N) << endl;
  };
  for (int i = 0; i < (N); ++i) {
    char c[3010];
    scanf("%s", c);
    W1[i] = string(c);
  }
  for (int i = 0; i < (N); ++i) {
    char c[3010];
    scanf("%s", c);
    W2[i] = string(c);
  }
  solve_inspired_by_kmjp();
  return 0;
}
