#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma GCC target( sse4 )   using namespace std;   using ii = pair<int, int>;   using ll = long long;   const int N = 3000 + 5;   const int mod = 1e9 + 7;   string source[N], target[N];   int n;   ii ranges[N];   vector<int> FAIL(string pat) {     int m = pat.size();     vector<int> F(m + 1);     int i = 0, j = -1;     F[0] = -1;     while (i < m) {       while (j >= 0 && pat[i] != pat[j]) j = F[j];       i++, j++;       F[i] = j;     }     return F;   }   bool check(string a, string b, string s, string t) {     vector<int> F = FAIL(s);     int i = 0, j = 0;     int n = a.size();     int m = s.size();     while (i < n) {       while (j >= 0 && a[i] != s[j]) j = F[j];       i++, j++;       if (j == m) {         int idx = i - j;         for (int k = 0; k < m; k++) {           a[k + idx] = t[k];         }         break;       }     }     return a == b;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n;     for (int i = 0; i < n; i++) cin >> source[i];     for (int i = 0; i < n; i++) cin >> target[i];     string s, t;     string prefix, suffix;     for (int i = 0; i < n; i++) {       if (source[i] != target[i]) {         int l = -1, r = -1;         for (int j = 0; j < source[i].size(); j++) {           if (source[i][j] != target[i][j]) r = j;           if (source[i][j] != target[i][j] && l == -1) l = j;         }         ranges[i] = {l, r};         if (s.empty()) {           s = source[i].substr(l, r - l + 1);           t = target[i].substr(l, r - l + 1);           prefix = source[i].substr(0, l);           suffix = source[i].substr(r + 1);           reverse(prefix.begin(), prefix.end());         } else {           if (s != source[i].substr(l, r - l + 1) ||               t != target[i].substr(l, r - l + 1)) {             cout <<  NO n ;             return 0;           }           string cprefix = source[i].substr(0, l);           string csuffix = source[i].substr(r + 1);           reverse(cprefix.begin(), cprefix.end());           string p, ss;           for (int j = 0;                j < min(cprefix.size(), prefix.size()) && cprefix[j] == prefix[j];                j++) {             p.push_back(prefix[j]);           }           for (int j = 0;                j < min(csuffix.size(), suffix.size()) && csuffix[j] == suffix[j];                j++) {             ss.push_back(suffix[j]);           }           prefix = p;           suffix = ss;         }       }     }     reverse(prefix.begin(), prefix.end());     s = prefix + s + suffix;     t = prefix + t + suffix;     for (int i = 0; i < n; i++) {       if (!check(source[i], target[i], s, t)) {         cout <<  NO n ;         return 0;       }     }     cout <<  YES n ;     cout << s <<   n ;     cout << t <<   n ;     return 0;   }   