#include <bits/stdc++.h>
using namespace std;
const long long base = 31;
const long long md = 1e9 + 7;
long long step[10000];
string st1[10000], st2[10000];
pair<string, string> merge_(pair<string, string> p1, pair<string, string> p2) {
  long long l1 = -1;
  long long r1 = -1;
  for (long long i = 0; i < p1.first.size(); i++)
    if (p1.first[i] != p1.second[i]) {
      if (l1 == -1) l1 = i;
      r1 = i;
    }
  long long l2 = -1;
  long long r2 = -1;
  for (long long i = 0; i < p2.first.size(); i++)
    if (p2.first[i] != p2.second[i]) {
      if (l2 == -1) l2 = i;
      r2 = i;
    }
  if (r1 - l1 != r2 - l2) {
    cout << "NO";
    exit(0);
  }
  for (long long i = l1; i <= r1; i++)
    if (p1.first[i] != p2.first[i - l1 + l2] ||
        p1.second[i] != p2.second[i - l1 + l2]) {
      cout << "NO";
      exit(0);
    }
  while (l1 - 1 >= 0 && l2 - 1 >= 0 && p1.first[l1 - 1] == p2.first[l2 - 1])
    l1--, l2--;
  while (r1 + 1 < p1.first.size() && r2 + 1 < p2.first.size() &&
         p1.first[r1 + 1] == p2.first[r2 + 1])
    r1++, r2++;
  pair<string, string> res;
  for (long long i = l1; i <= r1; i++) {
    res.first += p1.first[i];
    res.second += p1.second[i];
  }
  return res;
}
vector<long long> get_hesh(string st) {
  vector<long long> res;
  res.push_back(st[0] - 'a' + 1);
  for (long long i = 1; i < st.size(); i++)
    res.push_back((res.back() + (st[i] - 'a' + 1) * step[i]) % md);
  return res;
}
long long get(string st1, long long hesh, long long len) {
  vector<long long> vec = get_hesh(st1);
  if (vec.size() < len) return 0;
  if (vec[len - 1] == hesh) return 1;
  for (long long i = len; i < vec.size(); i++)
    if ((((vec[i] - vec[i - len]) % md + md) % md) ==
        hesh * step[i - len + 1] % md) {
      return i - len + 2;
    }
  return 0;
}
long long get_dif(string st1, string st2) {
  long long res = 0;
  while (st1[res] == st2[res]) res++;
  return res;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  step[0] = 1;
  for (long long i = 1; i <= 4000; i++) {
    step[i] = step[i - 1] * base;
    step[i] %= md;
  }
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> st1[i];
  for (long long i = 1; i <= n; i++) cin >> st2[i];
  vector<pair<string, string> > vec1, vec2;
  for (long long i = 1; i <= n; i++)
    if (st1[i] == st2[i])
      vec2.push_back({st1[i], st2[i]});
    else
      vec1.push_back({st1[i], st2[i]});
  pair<string, string> todo = vec1[0];
  for (long long i = 1; i < vec1.size(); i++) todo = merge_(vec1[i], todo);
  vector<long long> hesh = get_hesh(todo.first);
  for (auto i : vec2)
    if (get(i.first, hesh.back(), (long long)todo.first.size())) {
      cout << "NO";
      return 0;
    }
  for (auto i : vec1) {
    long long pos = get(i.first, hesh.back(), (long long)todo.first.size()) - 1;
    string res = "";
    for (long long j = 0; j < pos; j++) res += i.first[j];
    res += todo.second;
    for (long long j = pos + todo.first.size(); j < i.first.size(); j++)
      res += i.first[j];
    if (res != i.second) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES\n";
  cout << todo.first << '\n' << todo.second << '\n';
}
