#include <bits/stdc++.h>
using namespace std;
int n;
string s1[3004], s2[3004];
int m[3004];
int len[3004];
int st[3004], en[3004];
int cl[3004], cr[3004];
int z[10000];
void Z(string s) {
  int l = 1, r = 1;
  int n = s.size() - 1;
  for (int i = 2; i <= n; ++i) {
    if (r < i) {
      l = r = i;
      int st = 1;
      while (r <= n && s[r] == s[st]) {
        r++;
        st++;
      }
      z[i] = r - i;
      r--;
    } else {
      int k = i - l;
      k++;
      if (z[k] < r - i + 1) {
        z[i] = z[k];
      } else {
        l = i;
        int st = r - i + 2;
        r++;
        while (r <= n && s[r] == s[st]) {
          r++;
          st++;
        }
        z[i] = r - i;
        r--;
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> s1[i], len[i] = s1[i].size();
  for (int i = 1; i <= n; ++i) cin >> s2[i];
  string cur = "", curb = "";
  for (int i = 1; i <= n; ++i) {
    if (s1[i] == s2[i]) {
      m[i] = 1;
      continue;
    }
    st[i] = 0;
    while (s1[i][st[i]] == s2[i][st[i]]) st[i]++;
    en[i] = len[i] - 1;
    while (s1[i][en[i]] == s2[i][en[i]]) en[i]--;
    assert(en[i] >= st[i]);
    string tem, temb;
    for (int j = st[i]; j <= en[i]; ++j) tem += s1[i][j], temb += s2[i][j];
    if (cur == "") {
      cur = tem;
      curb = temb;
    } else {
      if (cur != tem || curb != temb) {
        cout << "NO\n";
        return 0;
      }
    }
    cl[i] = st[i] - 1, cr[i] = en[i] + 1;
  }
  string pre, suf;
  bool lpos = true, rpos = true;
  while (lpos || rpos) {
    char cc = '$';
    if (lpos) {
      for (int i = 1; i <= n; ++i) {
        if (m[i]) continue;
        if (cl[i] == -1) {
          lpos = 0;
          cc = '$';
          break;
        }
        if (cc == '$')
          cc = s1[i][cl[i]];
        else if (cc != s1[i][cl[i]]) {
          lpos = 0;
          cc = '$';
          break;
        }
        cl[i]--;
      }
      if (cc != '$') pre += cc;
    }
    if (rpos) {
      cc = '$';
      for (int i = 1; i <= n; ++i) {
        if (m[i]) continue;
        if (cr[i] == len[i]) {
          rpos = 0;
          cc = '$';
          break;
        }
        if (cc == '$')
          cc = s1[i][cr[i]];
        else if (cc != s1[i][cr[i]]) {
          rpos = 0;
          cc = '$';
          break;
        }
        cr[i]++;
      }
      if (cc != '$') suf += cc;
    }
  }
  reverse(pre.begin(), pre.end());
  string s = pre + cur + suf;
  string t = pre + curb + suf;
  int ls = s.length();
  string ss = " " + s + "$";
  for (int i = 1; i <= n; ++i) {
    string cur = ss + s1[i];
    Z(cur);
    int fn = -1;
    for (int j = ls + 2; j <= cur.size() - 1; ++j) {
      assert(z[j] <= ls);
      if (z[j] == ls) {
        fn = j - (ls + 2);
        break;
      }
    }
    if (m[i]) {
      if (fn != -1) {
        cout << "NO\n";
        return 0;
      }
    } else {
      assert(fn != -1);
      assert(fn <= st[i]);
      string ns;
      for (int j = 0; j <= fn - 1; ++j) ns += s1[i][j];
      ns += t;
      for (int j = fn + ls; j <= len[i] - 1; ++j) ns += s1[i][j];
      if (ns != s2[i]) {
        cout << "NO\n";
        return 0;
      }
    }
  }
  cout << "YES\n" << s << '\n' << t << '\n';
}
