#include <bits/stdc++.h>
using namespace std;
template <typename T>
T abs(T x) {
  return x > 0 ? x : -x;
}
template <typename T>
T sqr(T x) {
  return x * x;
}
template <typename T>
ostream &operator<<(ostream &s, const vector<T> &x) {
  s << "[";
  for (auto it : x) {
    s << it << ", ";
  }
  s << "]";
  return s;
}
template <typename T>
ostream &operator<<(ostream &s, const set<T> &x) {
  s << "{";
  for (auto it : x) {
    s << it << ", ";
  }
  s << "}";
  return s;
}
template <typename U, typename V>
ostream &operator<<(ostream &s, const pair<U, V> &x) {
  s << "(" << x.first << ", " << x.second << ")";
  return s;
}
template <typename T>
bool chmax(T &x, const T &y) {
  if (x < y) {
    x = y;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &x, const T &y) {
  if (x > y) {
    x = y;
    return true;
  }
  return false;
}
vector<int> prefix_function(const string &s) {
  int n = (int)s.length();
  vector<int> pi(n);
  for (int i = 1; i < n; ++i) {
    int j = pi[i - 1];
    while (j > 0 && s[i] != s[j]) j = pi[j - 1];
    if (s[i] == s[j]) ++j;
    pi[i] = j;
  }
  return pi;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<string> from(n), to(n);
  vector<int> left(n), right(n);
  for (int i = 0; i < n; ++i) {
    cin >> from[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> to[i];
  }
  int len = 0;
  int last_row = 0;
  for (int i = 0; i < n; ++i) {
    int m = from[i].length();
    left[i] = m, right[i] = -1;
    for (int j = 0; j < m; ++j) {
      if (from[i][j] != to[i][j]) {
        if (left[i] == m) {
          left[i] = j;
        }
        right[i] = j;
      }
    }
    if (right[i] - left[i] >= 0) {
      len = right[i] - left[i] + 1;
      last_row = i;
    }
  }
  bool fl = true;
  for (int i = 0; i < n && fl; ++i) {
    if (right[i] - left[i] < 0) {
      continue;
    }
    if (right[i] - left[i] + 1 != len) {
      fl = false;
      break;
    }
    for (int j = 0; j <= right[i] - left[i]; ++j) {
      if (from[last_row][left[last_row] + j] != from[i][left[i] + j] ||
          to[last_row][left[last_row] + j] != to[i][left[i] + j]) {
        fl = false;
        break;
      }
    }
  }
  if (!fl) {
    cout << "NO\n";
    return 0;
  }
  while (left[last_row] != 0) {
    bool goleft = true;
    for (int i = 0; i < n; ++i) {
      if (right[i] - left[i] < 0) {
        continue;
      }
      if (left[i] == 0 ||
          from[i][left[i] - 1] != from[last_row][left[last_row] - 1]) {
        goleft = false;
        break;
      }
    }
    if (!goleft) {
      break;
    }
    for (int i = 0; i < n; ++i) {
      if (right[i] - left[i] < 0) {
        continue;
      }
      --left[i];
    }
  }
  while (right[last_row] + 1 < from[last_row].length()) {
    bool goright = true;
    for (int i = 0; i < n; ++i) {
      if (right[i] - left[i] < 0) {
        continue;
      }
      if (right[i] + 1 >= from[i].length() ||
          from[last_row][right[last_row] + 1] != from[i][right[i] + 1]) {
        goright = false;
        break;
      }
    }
    if (!goright) {
      break;
    }
    for (int i = 0; i < n; ++i) {
      if (right[i] - left[i] < 0) {
        continue;
      }
      ++right[i];
    }
  }
  for (int i = 0; i < n; ++i) {
    string cur;
    for (int j = left[last_row]; j <= right[last_row]; ++j) {
      cur += from[last_row][j];
    }
    int pref = cur.length();
    cur += '\0';
    for (int j = 0; j < from[i].length(); ++j) {
      cur += from[i][j];
    }
    auto p = prefix_function(cur);
    for (int j = pref + 1; j < cur.length(); ++j) {
      if (p[j] == pref) {
        if (right[i] - left[i] < 0) {
          fl = false;
        }
        if (j != pref + 1 + right[i]) {
          fl = false;
        }
        break;
      }
    }
  }
  if (!fl) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  for (int i = left[last_row]; i <= right[last_row]; ++i) {
    cout << from[last_row][i];
  }
  cout << "\n";
  for (int i = left[last_row]; i <= right[last_row]; ++i) {
    cout << to[last_row][i];
  }
  cout << "\n";
  return 0;
}
