#include <bits/stdc++.h>
using namespace std;
const int maxn = 3000 + 5;
const int mod = 1e9 + 87, pr = 133;
string a[maxn], b[maxn], s[maxn], t[maxn];
int l[maxn], r[maxn];
int pw[maxn], ha[maxn][maxn], hb[maxn][maxn];
int get(int *h, int l, int r) {
  if (l == 0) return h[r];
  return (h[r] - 1ll * pw[r - l + 1] * h[l - 1] % mod + mod) % mod;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) cin >> b[i];
  pw[0] = 1;
  for (int i = 1; i < maxn; ++i) pw[i] = pw[i - 1] * 1ll * pr % mod;
  for (int i = 0; i < n; ++i) {
    ha[i][0] = a[i][0];
    hb[i][0] = b[i][0];
    for (int j = 1; j < a[i].size(); ++j) {
      ha[i][j] = (ha[i][j - 1] * 1ll * pr + a[i][j]) % mod;
      hb[i][j] = (hb[i][j - 1] * 1ll * pr + b[i][j]) % mod;
    }
  }
  for (int i = 0; i < n; ++i) {
    int j = 0, k = a[i].size() - 1;
    while (j < a[i].size() && a[i][j] == b[i][j]) ++j;
    while (k >= j && a[i][k] == b[i][k]) --k;
    s[i] = a[i].substr(j, k - j + 1);
    t[i] = b[i].substr(j, k - j + 1);
    l[i] = j;
    r[i] = k;
  }
  int lng = 0, whr = -1;
  for (int i = 0; i < n; ++i) {
    if (r[i] - l[i] + 1 > lng) {
      lng = r[i] - l[i] + 1;
      whr = i;
    }
  }
  for (int i = 0; i < n; ++i) {
    if (s[i].size() == 0) continue;
    if (s[i] != s[whr] || t[i] != t[whr]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  while (true) {
    bool br = false;
    char c = ' ';
    for (int i = 0; i < n && !br; ++i) {
      if (s[i].size() == 0) continue;
      if (l[i] == 0) {
        br = true;
        break;
      }
      if (c == ' ')
        c = a[i][l[i] - 1];
      else if (c != a[i][l[i] - 1])
        br = true;
    }
    if (br) break;
    for (int i = 0; i < n; ++i) {
      if (s[i].size() == 0) continue;
      --l[i];
    }
  }
  while (true) {
    bool br = false;
    char c = ' ';
    for (int i = 0; i < n && !br; ++i) {
      if (s[i].size() == 0) continue;
      if (r[i] == a[i].size() - 1) {
        br = true;
        break;
      }
      if (c == ' ')
        c = a[i][r[i] + 1];
      else if (c != a[i][r[i] + 1])
        br = true;
    }
    if (br) break;
    for (int i = 0; i < n; ++i) {
      if (s[i].size() == 0) continue;
      ++r[i];
    }
  }
  for (int i = 0; i < n; ++i) {
    s[i] = a[i].substr(l[i], r[i] - l[i] + 1);
    t[i] = b[i].substr(l[i], r[i] - l[i] + 1);
  }
  int hs = 0;
  for (int i = 0; i < s[whr].size(); ++i)
    hs = (hs * 1ll * pr + s[whr][i]) % mod;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < a[i].size(); ++j) {
      if (j + s[whr].size() > a[i].size()) break;
      if (get(ha[i], j, j + s[whr].size() - 1) == hs) {
        for (int k = 0; k < s[whr].size(); ++k) a[i][k + j] = t[whr][k];
        break;
      }
    }
    if (a[i] != b[i]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  cout << s[whr] << endl;
  cout << t[whr] << endl;
  return 0;
}
