Problem:
A - Unique Nickname
Time Limit: 2 sec
問題文
一般に「東大」といえば東京大学を、「北大」といえば北海道大学を指すために、東北大学には「〇大」のような二文字の愛称が存在しません。
唯一無二の愛称を探す tupc メンバーのために、次の問題に答えてください。
文字列 $A$ が文字列の組 $(B_1, B_2)$ の愛称であるとは、
$A$ は長さ $2$ の文字列である
$A$ の一文字目が $B_1$ に含まれている
$A$ の二文字目が $B_2$ に含まれている
ことを指すものとします。
文字列 $S_1, S_2$ と計 $2M$ 個の文字列 $T_{i1}, T_{i2} (1 \leq i \leq M)$ が与えられます。
$(S_1, S_2)$ の愛称であるが、任意の $1 \leq i \leq M$ に対して $(T_{i1}, T_{i2})$ の愛称とならないものが存在するか判定してください。また存在する場合には、そのような愛称のうち辞書順最小のものを答えてください。
制約
$1 \leq M \leq 100$
$M$ は整数
$S_1, S_2, T_{i1}, T_{i2}$ は英小文字からなる長さ $10000$ 以下の文字列 $(1 \leq i \leq M)$
入力
$M$
$S_1 \quad S_2$
$T_{11} \quad T_{12}$
$T_{21} \quad T_{22}$
$\vdots$
$T_{M1} \quad T_{M2}$
出力
条件を満たす愛称が存在する場合には
Yes
を、存在しない場合には
No
を出力してください。
さらに存在する場合には、その次の行に条件を満たす愛称のうち辞書順で最小のものを出力してください。
入力例1
2
cat dog
cow deer
kangaroo fox
出力例1
Yes
ad
cat dog の愛称として考えられるものは cd, ao, co など計 $9$ 個あります。
これら $9$ 個のうち、cd などは cow deer の愛称と、 ao などは kangaroo fox の愛称となり得るので、条件を満たさない愛称です。
しかし co などは条件を満たすため
Yes
と出力します。また、条件を満たす愛称のうち辞書順最小のものは
ad
です。
入力例2
2
tohoku university
hokkaido university
university tokyo
出力例2
Yes
te
入力例3
1
abcijk pqrxyz
abcdefghijklm nopqrstuvwxyz
出力例3
No

Submitted solutions:

code_snippet: // competitive-verifier: PROBLEM
#ifdef ATCODER
#pragma GCC target("sse4.2,avx512f,avx512dq,avx512ifma,avx512cd,avx512bw,avx512vl,bmi2")
#endif
#pragma GCC optimize("Ofast,fast-math,unroll-all-loops")
#include <bits/stdc++.h>
#ifndef ATCODER
#pragma GCC target("sse4.2,avx2,bmi2")
#endif
template <class T, class U>
constexpr bool chmax(T &a, const U &b) {
    return a < (T)b ? a = (T)b, true : false;
}
template <class T, class U>
constexpr bool chmin(T &a, const U &b) {
    return (T)b < a ? a = (T)b, true : false;
}
constexpr std::int64_t INF = 1000000000000000003;
constexpr int Inf = 1000000003;
constexpr double EPS = 1e-7;
constexpr double PI = 3.14159265358979323846;
#define FOR(i, m, n) for (int i = (m); i < int(n); ++i)
#define FORR(i, m, n) for (int i = (m)-1; i >= int(n); --i)
#define FORL(i, m, n) for (int64_t i = (m); i < int64_t(n); ++i)
#define rep(i, n) FOR (i, 0, n)
#define repn(i, n) FOR (i, 1, n + 1)
#define repr(i, n) FORR (i, n, 0)
#define repnr(i, n) FORR (i, n + 1, 1)
#define all(s) (s).begin(), (s).end()
struct Sonic {
    Sonic() {
        std::ios::sync_with_stdio(false);
        std::cin.tie(nullptr);
        std::cout << std::fixed << std::setprecision(20);
    }
    constexpr void operator()() const {}
} sonic;
using namespace std;
using ll = std::int64_t;
using ld = long double;
template <class T, class U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    return is >> p.first >> p.second;
}
template <class T>
std::istream &operator>>(std::istream &is, std::vector<T> &v) {
    for (T &i : v) is >> i;
    return is;
}
template <class T, class U>
std::ostream &operator<<(std::ostream &os, const std::pair<T, U> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}
template <class T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &v) {
    for (auto it = v.begin(); it != v.end(); ++it) os << (it == v.begin() ? "" : " ") << *it;
    return os;
}
template <class Head, class... Tail>
void co(Head &&head, Tail &&...tail) {
    if constexpr (sizeof...(tail) == 0) std::cout << head << '\n';
    else std::cout << head << ' ', co(std::forward<Tail>(tail)...);
}
template <class Head, class... Tail>
void ce(Head &&head, Tail &&...tail) {
    if constexpr (sizeof...(tail) == 0) std::cerr << head << '\n';
    else std::cerr << head << ' ', ce(std::forward<Tail>(tail)...);
}
void Yes(bool is_correct = true) { std::cout << (is_correct ? "Yes\n" : "No\n"); }
void No(bool is_not_correct = true) { Yes(!is_not_correct); }
void YES(bool is_correct = true) { std::cout << (is_correct ? "YES\n" : "NO\n"); }
void NO(bool is_not_correct = true) { YES(!is_not_correct); }
void Takahashi(bool is_correct = true) { std::cout << (is_correct ? "Takahashi" : "Aoki") << '\n'; }
void Aoki(bool is_not_correct = true) { Takahashi(!is_not_correct); }
int main(void) {
    int m;
    cin >> m;
    vector<string> s(2);
    cin >> s;
    vector<set<char>> ss(2);
    rep (i, 2) {
        for (auto c : s[i]) ss[i].emplace(c);
    }
    vector t(vector(m, vector(2, string())));
    cin >> t;
    vector<vector<set<char>>> tt(m, vector<set<char>>(2));
    rep (i, m) {
        rep (j, 2) {
            for (auto c : t[i][j]) tt[i][j].emplace(c);
        }
    }
    rep (a, 26) {
        rep (b, 26) {
            char c1 = 'a' + a;
            char c2 = 'a' + b;
            if (!ss[0].count(c1) || !ss[1].count(c2))
                continue;
            bool f = true;
            rep (i, m) {
                if (tt[i][0].count(c1) && tt[i][1].count(c2)) {
                    f = false;
                }
            }
            if (f) {
                Yes();
                cout << c1 << c2 << endl;
                return 0;
            }
        }
    }
    No();
    return 0;
}
accuracy: 1
time_ms: 60
memory_kb: 5636
final_rank: 17

code_snippet: #include <iostream>
#include <vector>
#include <string>
using namespace std;
const int B = 26;
const int N = 100;
int used[N][2][B];
signed main() {
	int n;
	cin >> n;
	vector<int> used1(B), used2(B);
	string a, b; cin >> a >> b;
	for (int i = 0; i < a.size(); i++) used1[a[i] - 'a'] = 1;
	for (int i = 0; i < b.size(); i++) used2[b[i] - 'a'] = 1;
	for (int t = 0; t < n; t++) {
		string a, b; cin >> a >> b;
		for (int i = 0; i < a.size(); i++) used[t][0][a[i] - 'a'] = 1;
		for (int i = 0; i < b.size(); i++) used[t][1][b[i] - 'a'] = 1;
	}
	for (int i = 0; i < B; i++) {
		for (int j = 0; j < B; j++) {
			if (used1[i] == 0 || used2[j] == 0) continue;
			int fl = 1;
			for (int p = 0; p < n; p++) {
				if (used[p][0][i] && used[p][1][j]) fl = 0;
			}
			if (!fl) continue;
			cout << "Yes" << endl;
			cout << (char)(i + 'a') << (char)(j + 'a') << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}
accuracy: 1
time_ms: 30
memory_kb: 3280
final_rank: 1

code_snippet: #include<bits/stdc++.h>
using namespace std;
int main(){
  int M;
  cin>>M;
  string S1,S2;
  cin>>S1>>S2;
  set<char>C1,C2;
  for(auto i:S1)C1.insert(i);
  for(auto i:S2)C2.insert(i);
  set<string>ok;
  for(auto i:C1){
    for(auto j:C2){
      string X=string(1,i)+""+string(1,j);
      ok.insert(X);
    }
  }
  for(int i=0;i<M;i++){
    string T1,T2;
    cin>>T1>>T2;
    set<char>D1,D2;
    for(auto j:T1)D1.insert(j);
    for(auto j:T2)D2.insert(j);
    for(auto j:D1){
      for(auto k:D2){
        string X=string(1,j)+""+string(1,k);
        if(ok.find(X)!=ok.end())ok.erase(X);
      }
    }
  }
  if(ok.empty()){
    cout<<"No\n";
  }else{
    cout<<"Yes\n";
    cout<<*ok.begin()<<'\n';
  }
}
accuracy: 1
time_ms: 50
memory_kb: 3552
final_rank: 10

code_snippet: #include <bits/stdc++.h>
using namespace std;

typedef int64_t ll;

int main(){
  int m;
  cin >> m;
  string s1,s2,t1,t2;
  cin >> s1 >> s2;
  
  sort(s1.begin(),s1.end());
  s1.erase(unique(s1.begin(),s1.end()),s1.end());
  sort(s2.begin(),s2.end());
  s2.erase(unique(s2.begin(),s2.end()),s2.end());
  int s1s=(int)s1.size(),s2s=(int)s2.size();
  
  vector ck(26,vector<bool>(26,false));
  for(int i=0;i<s1s;i++){
    for(int j=0;j<s2s;j++){
      ck[s1[i]-'a'][s2[j]-'a']=true;
      //cout << s1[i]-'a' << " " << s2[j]-'a' << endl;
    }
  }
  
  for(int k=0;k<m;k++){
    cin >> t1 >> t2;
    sort(t1.begin(),t1.end());
    t1.erase(unique(t1.begin(),t1.end()),t1.end());
    sort(t2.begin(),t2.end());
    t2.erase(unique(t2.begin(),t2.end()),t2.end());
    int t1s=(int)t1.size(),t2s=(int)t2.size();
    for(int i=0;i<t1s;i++){
      for(int j=0;j<t2s;j++){
        ck[t1[i]-'a'][t2[j]-'a']=false;
      }
    }
   
  }
  char a1='?',a2;
  for(int i=0;i<26;i++){
    for(int j=0;j<26;j++){ 
      if(ck[i][j]){ 
        a1=char('a'+i);
        a2=char('a'+j);
        goto end;
      }
    }
  }
  
end:  if(a1=='?') cout << "No" << endl;
      else cout << "Yes" << "\n" << a1 << a2 << endl;
}
accuracy: 1
time_ms: 50
memory_kb: 3500
final_rank: 9

code_snippet: #include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int m = ri();
	std::string s, t;
	std::cin >> s >> t;
	std::string x[m], y[m];
	for (int i = 0; i < m; i++) {
		std::cin >> x[i] >> y[i];
	}
	std::set<char> a0(s.begin(), s.end()), a1(t.begin(), t.end());
	char c0 = -1, c1 = -1;
	for (auto i : a0) {
		std::set<char> ban;
		for (int j = 0; j < m; j++) if (std::find(x[j].begin(), x[j].end(), i) != x[j].end()) {
			for (auto k : y[j]) ban.insert(k);
		}
		bool ok = false;
		for (auto j : a1) if (!ban.count(j)) {
			ok = true;
			c1 = j;
			break;
		}
		if (ok) {
			c0 = i;
			break;
		}
	}
	if (c0 == (char) -1) {
		puts("No");
	} else {
		puts("Yes");
		printf("%c%c\n", c0, c1);
	}
	
	return 0;
}
accuracy: 1
time_ms: 490
memory_kb: 5736
final_rank: 20

code_snippet: #include<iostream>
#include<vector>
using namespace std;
int main() {
  int M;
  string S1,S2;
  cin >> M;
  vector<vector<int>> ans(26,vector<int>(26,0));
  {
    cin >> S1 >> S2;
    vector<int> c1(26,0),c2(26,0);
    for(int i=0;i<S1.length();i++)c1[S1[i]-'a'] = 1;
    for(int i=0;i<S2.length();i++)c2[S2[i]-'a'] = 1;
    for(int i=0;i<26;i++)for(int j=0;j<26;j++)if(c1[i]*c2[j])ans[i][j] = 1;
  }
  while(M--) {
    cin >> S1 >> S2;
    vector<int> c1(26,0),c2(26,0);
    for(int i=0;i<S1.length();i++)c1[S1[i]-'a'] = 1;
    for(int i=0;i<S2.length();i++)c2[S2[i]-'a'] = 1;
    for(int i=0;i<26;i++)for(int j=0;j<26;j++)if(c1[i]*c2[j])ans[i][j] = 0;
  }
  for(int i=0;i<26;i++)for(int j=0;j<26;j++)if(ans[i][j]) {
    cout << "Yes" << endl << (char)(i+'a') << (char)(j+'a') << endl;
    return 0;
  }
  cout << "No" << endl;
}
accuracy: 1
time_ms: 20
memory_kb: 3488
final_rank: 5

code_snippet: #include <bits/stdc++.h>

using namespace std;

int main(){
    int M;
    cin >> M;
    pair<string, string> S;

    vector< pair<string, string> > T(M);

    cin >> S.first >> S.second;

    for(int i=0; i<M; i++){
        cin >> T.at(i).first >> T.at(i).second;
    }

    char alpha[] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

    sort(S.first.begin(), S.first.end());
    sort(S.second.begin(), S.second.end());

    for(int i=0; i< M; i++){
        sort(T.at(i).first.begin(), T.at(i).first.end());
        sort(T.at(i).second.begin(), T.at(i).second.end());
    }
    

    for(int i=0; i<(int)(sizeof(alpha)/sizeof(char)); i++){
        for(int j=0; j<(int)(sizeof(alpha)/sizeof(char)); j++){
            
            if(binary_search(S.first.begin(),S.first.end(),alpha[i]) && binary_search(S.second.begin(),S.second.end(),alpha[j])){
                bool ok = true;
                for(int k=0; k<M; k++){
                    string Tf = T.at(k).first;
                    string Ts = T.at(k).second;

                    if(binary_search(Tf.begin(), Tf.end(), alpha[i]) && binary_search(Ts.begin(), Ts.end(), alpha[j])){
                        ok = false;
                        break;
                    } 
                    

                }
                if(ok){
                    for(int k=0; k<M; k++){
                        string Tf = T.at(k).first;
                        string Ts = T.at(k).second;
                        if(!binary_search(Tf.begin(), Tf.end(), alpha[i]) || !binary_search(Ts.begin(), Ts.end(), alpha[j])){
                            cout << "Yes" << endl;
                            cout << alpha[i] << alpha[j] << endl;
                            return 0;
                        }
                    }
                }
            }
            
        }
    }

    cout << "No" << endl;
}
accuracy: 1
time_ms: 70
memory_kb: 5428
final_rank: 16

code_snippet: #include <iostream>
#include <string>
#include <string.h>
#include <set>
using namespace std;
void f(string s,int (&cs)[27]){
	memset(cs,0,sizeof(cs));
	for(int i=0;i<s.size();i++){
		cs[s[i]-'a']=1;
	}
}

set<string> ss;

int main() {
	string s1,s2;
	int n;
	cin>>n;
	cin>>s1>>s2;
	int cs1[27];
	int cs2[27];
	int cs3[27];
	int cs4[27];


	f(s1,cs1);
	f(s2,cs2);
	string ans="No",ans2="  ";
	

	for(int i=0;i<n;i++){
		string t1,t2;
		cin>>t1>>t2;
		f(t1,cs3);
		f(t2,cs4);
	
		for(int p1=0;p1<27;p1++){
			if(cs1[p1]==0)continue;
			for(int p2=0;p2<27;p2++){
				if(cs2[p2]==0)continue;
				ans2[0]='a'+p1;
				ans2[1]='a'+p2;
				if(cs3[p1]==0||cs4[p2]==0){
					ans="Yes";
					if(i==0){
						ss.insert(ans2);
					}
				}else{
					ss.erase(ans2);
				}
			}
		}
	}



	if(ss.size()>0){
		ans2=(*(ss.begin()));
		cout<<"Yes"<<endl<<ans2<<endl;
	}else{
		cout<<"No"<<endl;
	}
	
	return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 3296
final_rank: 2

code_snippet: #include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template<class t> using vc = vector<t>;
template<class t> using vvc = vc<vc<t>>;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using vi = vc<int>;
using vvi = vvc<int>;
using vl = vc<ll>;
using vvl = vvc<ll>;

#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define irep(i,a,b) for (int i = (a); i > (b); i--)
#define all(a) a.begin(),a.end()
#define print(n) cout << n << '\n'
#define pritn(n) print(n)
#define printv(n,a) {copy(all(n),ostream_iterator<a>(cout," ")); cout<<"\n";}
#define printvv(n,a) {for(auto itr:n) printv(itr,a);}
#define rup(a,b) (a+b-1)/b
#define input(A,N) rep(i,0,N) cin>>A[i]
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)


int main(){
    cout << fixed << setprecision(15);
    
    int m;
    cin>>m;
    string a,b;
    cin>>a>>b;
    string c,d;
    vc<string> s;
    vvi aa(26,vi(26,0));
    sort(all(a));
    sort(all(b));
    a.erase(unique(all(a)),a.end());
    b.erase(unique(all(b)),b.end());
    int cnt = 0;
    rep(i,0,m){
        cin>>c>>d;
        sort(all(c));
        sort(all(d));
        c.erase(unique(all(c)),c.end());
        d.erase(unique(all(d)),d.end());
        rep(i,0,c.size()){
            rep(j,0,d.size()){
                aa[c[i]-'a'][d[j]-'a']++;
            }
        }
    }
    sort(all(s));
    s.erase(unique(all(s)),s.end());
    string ans = "";
    int nn = 0;

    rep(i,0,a.size()){
        rep(j,0,b.size()){
            if(aa[a[i]-'a'][b[j]-'a']) continue;
            string now = string(1,a[i]) + string(1,b[j]);
            if(nn++) chmin(ans,now);
            else ans = now;
        }
    }
    if(nn==0) print("No");
    else {
        print("Yes");
        print(ans);
    }
    //system("pause");
    return 0;
}
accuracy: 1
time_ms: 50
memory_kb: 3472
final_rank: 8

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vvvvll = vector<vvvll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vvvvb = vector<vvvb>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
#define all(A) A.begin(),A.end()
#define ALL(A) A.begin(),A.end()
#define rep(i, n) for (ll i = 0; i < (ll) (n); i++)
using pqr = priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>;

template<class T>
bool chmax(T& p, T q, bool C = 1) {
    if (C == 0 && p == q) {
        return 1;
    }
    if (p < q) {
        p = q;
        return 1;
    }
    else {
        return 0;
    }
}

template<class T>
bool chmin(T& p, T q, bool C = 1) {
    if (C == 0 && p == q) {
        return 1;
    }
    if (p > q) {
        p = q;
        return 1;
    }
    else {
        return 0;
    }
}

ll gcd(ll(a), ll(b)) {
    if (b == 0)return a;
    ll c = a;
    while (a % b != 0) {
        c = a % b;
        a = b;
        b = c;
    }
    return b;
}
void warshall_floyd(int n, vvll& d) {
    for (int k = 0; k < n; k++) {       // 経由する頂点
        for (int i = 0; i < n; i++) {    // 始点
            for (int j = 0; j < n; j++) {  // 終点
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

double dis(ll a, ll b, ll c, ll d) {
    return sqrt(double((a - c) * (a - c) + (b - d) * (b - d)));
}

int main() {

    ll M;
    cin>>M;
    vector<bool> t1(26,false),t2(26,false);
    vvb s1(M,vb(26,false)),s2(M,vb(26,false));
    string S1,S2;
    cin>>S1>>S2;
    rep(i,S1.size())t1[S1[i]-'a']=1;
    rep(i,S2.size())t2[S2[i]-'a']=1;

    rep(m,M){
        string T1,T2;
        cin>>T1>>T2;
        rep(i,T1.size())s1[m][T1[i]-'a']=1;
        rep(i,T2.size())s2[m][T2[i]-'a']=1;
    }

    rep(i,26){
        rep(j,26){
            if(t1[i]&&t2[j]){
                bool OK=1;
                rep(m,M){
                    if(s1[m][i]&&s2[m][j])OK=0;
                }
                if(OK){
                    cout<<"Yes"<<endl;
                    cout<<char('a'+i)<<char('a'+j)<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"No"<<endl;

}
accuracy: 1
time_ms: 20
memory_kb: 3436
final_rank: 3

code_snippet: #include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <forward_list>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template <typename T, typename V>
void ndarray(vector<T>& vec, const V& val, int len) { vec.assign(len, val); }
template <typename T, typename V, typename... Args> void ndarray(vector<T>& vec, const V& val, int len, Args... args) { vec.resize(len), for_each(begin(vec), end(vec), [&](T& v) { ndarray(v, val, args...); }); }
template <typename T> bool chmax(T &m, const T q) { return m < q ? (m = q, true) : false; }
template <typename T> bool chmin(T &m, const T q) { return m > q ? (m = q, true) : false; }
int floor_lg(long long x) { return x <= 0 ? -1 : 63 - __builtin_clzll(x); }
template <typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template <typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
template <typename T> vector<T> sort_unique(vector<T> vec) { sort(vec.begin(), vec.end()), vec.erase(unique(vec.begin(), vec.end()), vec.end()); return vec; }
template <typename T> int arglb(const std::vector<T> &v, const T &x) { return std::distance(v.begin(), std::lower_bound(v.begin(), v.end(), x)); }
template <typename T> int argub(const std::vector<T> &v, const T &x) { return std::distance(v.begin(), std::upper_bound(v.begin(), v.end(), x)); }
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (auto &v : vec) is >> v; return is; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { os << '['; for (auto v : vec) os << v << ','; os << ']'; return os; }
template <typename T, size_t sz> ostream &operator<<(ostream &os, const array<T, sz> &arr) { os << '['; for (auto v : arr) os << v << ','; os << ']'; return os; }
#if __cplusplus >= 201703L
template <typename... T> istream &operator>>(istream &is, tuple<T...> &tpl) { std::apply([&is](auto &&... args) { ((is >> args), ...);}, tpl); return is; }
template <typename... T> ostream &operator<<(ostream &os, const tuple<T...> &tpl) { os << '('; std::apply([&os](auto &&... args) { ((os << args << ','), ...);}, tpl); return os << ')'; }
#endif
template <typename T> ostream &operator<<(ostream &os, const deque<T> &vec) { os << "deq["; for (auto v : vec) os << v << ','; os << ']'; return os; }
template <typename T> ostream &operator<<(ostream &os, const set<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <typename T, typename TH> ostream &operator<<(ostream &os, const unordered_set<T, TH> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <typename T> ostream &operator<<(ostream &os, const multiset<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa) { os << '(' << pa.first << ',' << pa.second << ')'; return os; }
template <typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp) { os << '{'; for (auto v : mp) os << v.first << "=>" << v.second << ','; os << '}'; return os; }
template <typename TK, typename TV, typename TH> ostream &operator<<(ostream &os, const unordered_map<TK, TV, TH> &mp) { os << '{'; for (auto v : mp) os << v.first << "=>" << v.second << ','; os << '}'; return os; }
#ifdef HITONANODE_LOCAL
const string COLOR_RESET = "\033[0m", BRIGHT_GREEN = "\033[1;32m", BRIGHT_RED = "\033[1;31m", BRIGHT_CYAN = "\033[1;36m", NORMAL_CROSSED = "\033[0;9;37m", RED_BACKGROUND = "\033[1;41m", NORMAL_FAINT = "\033[0;2m";
#define dbg(x) cerr << BRIGHT_CYAN << #x << COLOR_RESET << " = " << (x) << NORMAL_FAINT << " (L" << __LINE__ << ") " << __FILE__ << COLOR_RESET << endl
#define dbgif(cond, x) ((cond) ? cerr << BRIGHT_CYAN << #x << COLOR_RESET << " = " << (x) << NORMAL_FAINT << " (L" << __LINE__ << ") " << __FILE__ << COLOR_RESET << endl : cerr)
#else
#define dbg(x) (x)
#define dbgif(cond, x) 0
#endif

string sort_unique(string vec) {
    sort(vec.begin(), vec.end()), vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

int main() {
    int M;
    cin >> M;

    using P = pair<string, string>;
    auto is_aisho = [&](int a, int b, const P &p) -> bool {
        return count(ALL(p.first), (char)('a' + a)) and count(ALL(p.second), (char)('a' + b));
    };

    P S;
    cin >> S.first >> S.second;
    S.first = sort_unique(S.first);
    S.second = sort_unique(S.second);

    vector<P> T(M);
    for (auto &[a, b] : T) {
        cin >> a >> b;
        a = sort_unique(a);
        b = sort_unique(b);
    }

    const int D = 26;
    REP(a, D) REP(b, D) {
        if (!is_aisho(a, b, S)) continue;
        bool bad = false;
        for (const auto &p : T) {
            if (is_aisho(a, b, p)) {
                bad = true;
                break;
            }
        }
        if (!bad) {
            cout << "Yes\n" << (char)('a' + a) << (char)('a' + b) << '\n';
            return 0;
        }
    }
    puts("No");
}
accuracy: 1
time_ms: 30
memory_kb: 5188
final_rank: 11

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define BIG_NUM 2000000000
#define HUGE_NUM 4000000000000000000 //オーバーフローに注意
#define MOD 1000000007
#define EPS 0.000000001



#define SIZE 10005

int A[26],B[26];
int table[SIZE][2][26];

int main(){

	int N;
	scanf("%d",&N);

	string S1,S2;

	cin >> S1 >> S2;

	for(int i = 0; i < S1.size(); i++){

		A[S1[i]-'a']++;
	}
	for(int i = 0; i < S2.size(); i++){

		B[S2[i]-'a']++;
	}


	for(int i = 0; i < N; i++){

		string T1,T2;

		cin >> T1 >> T2;
		for(int k = 0; k < T1.size(); k++){

			table[i][0][T1[k]-'a']++;
		}
		for(int k = 0; k < T2.size(); k++){

			table[i][1][T2[k]-'a']++;
		}
	}

	for(int i = 0; i < 26; i++){
		for(int k = 0; k < 26; k++){
			if(A[i] == 0 || B[k] == 0)continue;

			bool FLG = true;
			for(int p = 0; p < N; p++){

				if(table[p][0][i] > 0 && table[p][1][k] > 0){

					FLG = false;
					break;
				}
			}
			if(FLG){
				printf("Yes\n");
				printf("%c%c\n",'a'+i,'a'+k);
				return 0;
			}
		}
	}

	printf("No\n");

	return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 3364
final_rank: 4

code_snippet: #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int M; cin >> M;
    pair<string,string> S;
    cin >> S.first >> S.second;
    sort(S.first.begin(), S.first.end());
    sort(S.second.begin(), S.second.end());
    vector<pair<string,string>> T(M);
    rep(i,M) {
        cin >> T[i].first >> T[i].second;
        sort(T[i].first.begin(), T[i].first.end());
        sort(T[i].second.begin(), T[i].second.end());
    }
    

    set<string> se;
    for(char c = 'a'; c <= 'z'; c++) {
        for(char d = 'a'; d <= 'z'; d++) {
            string A = "";
            A += c;
            A += d;
            if(binary_search(S.first.begin(), S.first.end(), c) && binary_search(S.second.begin(), S.second.end(), d)) {
                int ok = 1;
                rep(i,M) {
                    ok &= !(binary_search(T[i].first.begin(), T[i].first.end(), c) && binary_search(T[i].second.begin(), T[i].second.end(), d));
                }
                if(ok) {
                    se.insert(A);
                }
            }
        }
    }

    if(se.size() >= 1) {
        cout << "Yes" << endl;
        cout << *se.begin() << endl;
    } else {
        cout << "No"  << endl;
    }
}
accuracy: 1
time_ms: 30
memory_kb: 5364
final_rank: 12

code_snippet: #pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <sstream>
#include <utility>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <array>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}
inline ll time() {
    return static_cast<long double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int m; cin >> m;
    string s,t; cin >> s >> t;
    sort(s.begin(), s.end());
    s.erase(unique(s.begin(), s.end()),s.end());
    sort(t.begin(), t.end());
    t.erase(unique(t.begin(), t.end()),t.end());
    vector<vector<bool>> ok(26,vector<bool>(26,true));
    for(int i=0;i<m;i++){
        string a,b; cin >> a >> b;
        sort(a.begin(), a.end());
        a.erase(unique(a.begin(), a.end()),a.end());
        sort(b.begin(), b.end());
        b.erase(unique(b.begin(), b.end()),b.end());
        for(char c:a){
            for(char cc:b){
                ok[c-'a'][cc-'a'] = false;
            }
        }
    }
    string res = "";
    for(char c:s){
        for(char cc:t){
            if(ok[c-'a'][cc-'a']){
                string r = "";
                r += c;
                r += cc;
                if(res == "") res = r;
                res = min(res, r);
            }
        }
    }
    if(res == ""){
        cout << "No" << "\n";
    }
    else{
        cout << "Yes" << "\n";
        cout << res << "\n";
    }
}
accuracy: 1
time_ms: 30
memory_kb: 3592
final_rank: 7

code_snippet: /*	author:  Kite_kuma
	created: 2022.03.13 10:43:21 */

// #ifdef LOCAL
// #define _GLIBCXX_DEBUG
// #endif
#include <bits/stdc++.h>
using namespace std;

#pragma region macros

#define foa(s, v) for(auto &s : v)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcnt(n) __builtin_popcountll((long long)n)

#define REPname(a, b, c, d, e, ...) e
#define rep(...) REPname(__VA_ARGS__, REP3, REP2, REP1, REP0)(__VA_ARGS__)
#define REP0(x) for(int Counter_in_rep_macro = 0; Counter_in_rep_macro < (x); ++Counter_in_rep_macro)
#define REP1(i, x) for(int i = 0; i < (x); ++i)
#define REP2(i, l, r) for(int i = (l); i < (r); ++i)
#define REP3(i, l, r, c) for(int i = (l); i < (r); i += (c))

#define DREPname(a, b, c, d, e, ...) e
#define drep(...) DREPname(__VA_ARGS__, DREP3, DREP2, DREP1)(__VA_ARGS__)
#define DREP1(i, x) for(int i = (x)-1; i >= 0; --i)
#define DREP2(i, l, r) for(int i = (r)-1; i >= (l); --i)
#define DREP3(i, l, r, c) for(int i = (r)-1; i >= (l); i -= (c))

#pragma endregion

#pragma region aliases

using ll = long long;
using ld = long double;
using ull = unsigned long long;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vvvi = std::vector<std::vector<std::vector<int>>>;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
template <class T = ll>
using V = std::vector<T>;
template <class T = ll>
using VV = V<V<T>>;
template <class T = ll>
using VVV = V<V<V<T>>>;
template <class T = ll>
using pqup = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T = ll>
using pqdn = std::priority_queue<T>;

#pragma endregion

#pragma region constants

const int inf = 1e9;
const long long INF = 1e18;
const long double pi = acos(-1);
const char dl = '\n';
const char sp = ' ';
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

const int mod_1000000007 = 1000000007;
const int mod_998244353 = 998244353;

#pragma endregion

#pragma region basic_operation

template <class T0, class T1, class T2>
inline bool in_range(T0 x, T1 lef, T2 rig) {
	return ((lef <= x) && (x < rig));
}

template <class T>
inline bool chmin(T &a, T b) {
	if(a > b) {
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b) {
	if(a < b) {
		a = b;
		return true;
	}
	return false;
}

void Yes(bool f = 1) { std::cout << (f ? "Yes" : "No") << '\n'; }
void No() { std::cout << "No\n"; }
void YES(bool f = 1) { std::cout << (f ? "YES" : "NO") << '\n'; }
void NO() { std::cout << "NO\n"; }

template <class T>
void drop(T answer) {
	std::cout << answer << '\n';
	exit(0);
}

void err(bool flag = true) {
	if(!flag) return;
	std::cout << -1 << '\n';
	exit(0);
}

template <class T>
void vout(std::vector<T> const &v, bool vertically = 0) {
	if(vertically) {
		for(auto const &a : v) {
			std::cout << a << '\n';
		}
		return;
	}
	for(auto it = v.begin(); it != v.end(); it++) {
		std::cout << (*it);
		if(it != v.end() - 1) {
			std::cout << ' ';
		}
	}
	std::cout << '\n';
	return;
}

inline void print() { std::cout << '\n'; }
template <class T>
inline void print(T x) {
	std::cout << x << '\n';
	return;
}
template <typename Head, typename... Tail>
void print(Head H, Tail... T) {
	std::cout << H << " ";
	print(T...);
}

template <class T>
void add(std::vector<T> &v, T val) {
	for(auto &a : v) a += val;
	return;
}

template <class T>
T dup(T a, T b) {
	assert(b != 0);
	return (a + b - 1) / b;
}

template <class T>
T greatest_lower_multiple(T x, T d) {
	if(d == 0) return 0;
	if(d < 0) d *= -1;
	T y = x % d;
	if(y < 0) y += d;
	return x - y;
}

template <class T>
T least_upper_multiple(T x, T d) {
	return -greatest_lower_multiple(-x, d);
}

long long POW(long long a, long long n) {
	long long res = 1;
	while(n > 0) {
		if(n & 1) res = res * a;
		a = a * a;
		n >>= 1;
	}
	return res;
}

long long modpow(long long a, long long n, long long mod) {	 // a^n mod
	assert(n >= 0 && mod);
	if(mod == 1) return 0LL;
	long long res = 1;
	a %= mod;
	while(n > 0) {
		if(n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res < 0 ? res + mod : res;
}

// return x which satisfies a * x % mod == gcd(a, mod)
// not (mod | a)
long long modinv(long long a, long long mod) {
	long long b = mod, u = 1, v = 0;
	while(b) {
		long long t = a / b;
		a -= t * b;
		std::swap(a, b);
		u -= t * v;
		std::swap(u, v);
	}
	u %= mod;
	if(u < 0) u += mod;
	return u;
}

template <class T>
int lb(const std::vector<T> &a, const T x) {
	return std::distance(a.begin(), std::lower_bound(a.begin(), a.end(), x));
}
template <class T>
int ub(const std::vector<T> &a, const T x) {
	return std::distance(a.begin(), std::upper_bound(a.begin(), a.end(), x));
}
template <class T>
void unq_sort(std::vector<T> &a) {
	std::sort(a.begin(), a.end());
	a.erase(std::unique(a.begin(), a.end()), a.end());
}
template <class T>
std::vector<int> press(std::vector<T> &a) {
	auto vec = a;
	unq_sort(vec);
	std::vector<int> ret;
	for(auto &v : a) ret.push_back(lb(vec, v));
	return ret;
}

#pragma endregion

#pragma region input
#define VEC(type, name, size) \
	vector<type> name(size);  \
	scanner::INPUT(name)
#define VVEC(type, name, h, w)                     \
	vector<vector<type>> name(h, vector<type>(w)); \
	scanner::INPUT(name)
#define INT(...)     \
	int __VA_ARGS__; \
	scanner::INPUT(__VA_ARGS__)
#define LL(...)            \
	long long __VA_ARGS__; \
	scanner::INPUT(__VA_ARGS__)
#define STR(...)        \
	string __VA_ARGS__; \
	scanner::INPUT(__VA_ARGS__)
#define CHR(...)      \
	char __VA_ARGS__; \
	scanner::INPUT(__VA_ARGS__)
#define DBL(...)        \
	double __VA_ARGS__; \
	scanner::INPUT(__VA_ARGS__)
#define LD(...)              \
	long double __VA_ARGS__; \
	scanner::INPUT(__VA_ARGS__)
#define TPL3(type0, type1, type2, name)   \
	std::tuple<type0, type1, type2> name; \
	scanner::INPUT(name);
#define TPL4(type0, type1, type2, type3, name)   \
	std::tuple<type0, type1, type2, type3> name; \
	scanner::INPUT(name);

namespace scanner {
template <class T>
void scan(T &a) {
	std::cin >> a;
}

template <class T, class L>
void scan(std::pair<T, L> &p) {
	scan(p.first);
	scan(p.second);
}

template <class T0, class T1, class T2>
void scan(std::tuple<T0, T1, T2> &p) {
	T0 t0;
	T1 t1;
	T2 t2;
	scan(t0);
	scan(t1);
	scan(t2);
	p = std::make_tuple(t0, t1, t2);
}

template <class T0, class T1, class T2, class T3>
void scan(std::tuple<T0, T1, T2, T3> &p) {
	T0 t0;
	T1 t1;
	T2 t2;
	T3 t3;
	scan(t0);
	scan(t1);
	scan(t2);
	scan(t3);
	p = std::make_tuple(t0, t1, t2, t3);
}

template <class T>
void scan(std::vector<T> &a) {
	for(auto &i : a) scan(i);
}

void INPUT() {}
template <class Head, class... Tail>
void INPUT(Head &head, Tail &... tail) {
	scan(head);
	INPUT(tail...);
}
}  // namespace scanner

template <typename T1, typename T2>
std::istream &operator>>(std::istream &is, std::pair<T1, T2> &p) {
	is >> p.first >> p.second;
	return is;
}
#pragma endregion

#pragma region debug

#pragma region output
template <typename T1, typename T2>
std::ostream &std::operator<<(std::ostream &os, const std::pair<T1, T2> &p) {
	os << p.first << " " << p.second;
	return os;
}
template <class T>
std::ostream &std::operator<<(std::ostream &os, const std::vector<T> &v) {
	for(int i = 0; i < (int)v.size(); i++) {
		if(i) os << " ";
		os << v[i];
	}
	return os;
}
#pragma endregion

#pragma region view

namespace viewer {
void view(const long long e) {
	if(e == INF)
		std::cerr << "INF";
	else if(e == -INF)
		std::cerr << "-INF";
	else
		std::cerr << e;
}

void view(const int e) {
	if(e == inf)
		std::cerr << "inf";
	else if(e == -inf)
		std::cerr << "-inf";
	else
		std::cerr << e;
}

template <typename T>
void view(const T e) {
	std::cerr << e;
}

template <typename T, typename U>
void view(const std::pair<T, U> &p) {
	std::cerr << "(";
	view(p.first);
	std::cerr << ", ";
	view(p.second);
	std::cerr << ")";
}

template <class T0, class T1, class T2>
void view(const std::tuple<T0, T1, T2> &p) {
	std::cerr << "(";
	view(std::get<0>(p));
	std::cerr << ", ";
	view(std::get<1>(p));
	std::cerr << ", ";
	view(std::get<2>(p));
	std::cerr << ")";
}

template <class T0, class T1, class T2, class T3>
void view(const std::tuple<T0, T1, T2, T3> &p) {
	std::cerr << "(";
	view(std::get<0>(p));
	std::cerr << ", ";
	view(std::get<1>(p));
	std::cerr << ", ";
	view(std::get<2>(p));
	std::cerr << ", ";
	view(std::get<3>(p));
	std::cerr << ")";
}

template <typename T>
void view(const std::set<T> &s) {
	if(s.empty()) {
		std::cerr << "{ }";
		return;
	}
	std::cerr << "{ ";
	for(auto &t : s) {
		view(t);
		std::cerr << ", ";
	}
	std::cerr << "\b\b }";
}

template <typename T>
void view(const std::unordered_set<T> &s) {
	if(s.empty()) {
		std::cerr << "{ }";
		return;
	}
	std::cerr << "{ ";
	for(auto &t : s) {
		view(t);
		std::cerr << ", ";
	}
	std::cerr << "\b\b }";
}

template <typename T>
void view(const std::vector<T> &v) {
	if(v.empty()) {
		std::cerr << "{ }";
		return;
	}
	std::cerr << "{ ";
	for(const auto &e : v) {
		view(e);
		std::cerr << ", ";
	}
	std::cerr << "\b\b }";
}

template <typename T>
void view(const std::vector<std::vector<T>> &vv) {
	std::cerr << "{\n";
	for(const auto &v : vv) {
		std::cerr << "\t";
		view(v);
		std::cerr << '\n';
	}
	std::cerr << "}";
}

template <typename T, typename U>
void view(const std::vector<std::pair<T, U>> &v) {
	std::cerr << "{\n";
	for(const auto &c : v) {
		std::cerr << "\t(";
		view(c.first);
		std::cerr << ", ";
		view(c.second);
		std::cerr << ")\n";
	}
	std::cerr << "}";
}

template <class T0, class T1, class T2>
void view(const std::vector<std::tuple<T0, T1, T2>> &v) {
	if(v.empty()) {
		std::cerr << "{ }";
		return;
	}
	std::cerr << '{';
	for(const auto &t : v) {
		std::cerr << "\n\t";
		view(t);
		std::cerr << ",";
	}
	std::cerr << "\n}";
}

template <class T0, class T1, class T2, class T3>
void view(const std::vector<std::tuple<T0, T1, T2, T3>> &v) {
	if(v.empty()) {
		std::cerr << "{ }";
		return;
	}
	std::cerr << '{';
	for(const auto &t : v) {
		std::cerr << "\n\t";
		view(t);
		std::cerr << ",";
	}
	std::cerr << "\n}";
}

template <typename T, typename U>
void view(const std::map<T, U> &m) {
	std::cerr << "{\n";
	for(const auto &t : m) {
		std::cerr << "\t[";
		view(t.first);
		std::cerr << "] : ";
		view(t.second);
		std::cerr << '\n';
	}
	std::cerr << "}";
}

template <typename T, typename U>
void view(const std::unordered_map<T, U> &m) {
	std::cerr << "{\n";
	for(const auto &t : m) {
		std::cerr << "\t[";
		view(t.first);
		std::cerr << "] : ";
		view(t.second);
		std::cerr << '\n';
	}
	std::cerr << "}";
}
}  // namespace viewer

#pragma endregion

// when debugging : g++ foo.cpp -DLOCAL
#ifdef LOCAL
void debug_out() {}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	viewer::view(H);
	std::cerr << ", ";
	debug_out(T...);
}
#define debug(...)                                                \
	do {                                                          \
		std::cerr << __LINE__ << " [" << #__VA_ARGS__ << "] : ["; \
		debug_out(__VA_ARGS__);                                   \
		std::cerr << "\b\b]\n";                                   \
	} while(0)
#define dump(x)                                      \
	do {                                             \
		std::cerr << __LINE__ << " " << #x << " : "; \
		viewer::view(x);                             \
		std::cerr << '\n';                           \
	} while(0)

#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

#pragma endregion

void unq(string &s) {
	sort(all(s));
	s.erase(unique(all(s)), s.end());
	return;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout << std::fixed << std::setprecision(15);
	srand((unsigned)time(NULL));

	int m;
	cin >> m;
	auto included = [](char c, const string &s) {
		foa(ch, s) if(ch == c) return true;
		return false;
	};
	auto is_nickname = [&included](string nk, const string &a, const string &b) {
		if(nk.size() != 2) return false;
		return included(nk.front(), a) && included(nk.back(), b);
	};

	auto nkname = [&is_nickname](string nk, const pair<string, string> &pr) { return is_nickname(nk, pr.first, pr.second); };

	vector<pair<string, string>> names;
	rep(m + 1) {
		string a, b;
		cin >> a >> b;
		sort(all(a));
		unq(a);
		unq(b);
		names.emplace_back(a, b);
	}

	auto ok = [&](string nk) {
		rep(i, m + 1) {
			if(nkname(nk, names[i]) == bool(i)) return false;
		}
		return true;
	};

	rep(i, 26) rep(j, 26) {
		char a, b;
		a = 'a' + i;
		b = 'a' + j;
		string s;
		s += a;
		s += b;

		if(ok(s)) {
			// drop("Yes");
			Yes();
			drop(s);
		}
	}
	No();
	return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 3500
final_rank: 6

code_snippet: #include <iostream>
#include <string>
#include <vector>
using namespace std;


int main(){
    int m; cin >> m;
    string s1, s2; cin >> s1 >> s2;
    vector<string> t1(m), t2(m);
    for(int i = 0; i < m; i++) cin >> t1[i] >> t2[i];

    vector<vector<bool>> u1(m, vector<bool>(26, false)), u2(m, vector<bool>(26, false));
    for(int i = 0; i < m; i++){
        for(auto &it: t1[i]) u1[i][it-'a'] = true;
        for(auto &it: t2[i]) u2[i][it-'a'] = true;
    }
    vector<bool> r1(26, false), r2(26, false);
    for(auto &it: s1) r1[it-'a'] = true;
    for(auto &it: s2) r2[it-'a'] = true;
    for(char ch1 = 'a'; ch1 <= 'z'; ch1++){
        for(char ch2 = 'a'; ch2 <= 'z'; ch2++){
            if(!r1[ch1-'a'] || !r2[ch2-'a']) continue;
            bool isexist = false;
            for(int i = 0; i < m; i++){
                if(u1[i][ch1-'a'] && u2[i][ch2-'a']) isexist = true;
            }
            if(!isexist){
                cout << "Yes" << endl;
                cout << ch1 << ch2 << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;   
}
accuracy: 1
time_ms: 20
memory_kb: 6032
final_rank: 15

code_snippet: #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
//#define mod 998244353
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline void out(T a){ cout << a << '\n'; }
void YN(bool ok){if(ok) cout << "Yes" << endl; else cout << "No" << endl;}
//void YN(bool ok){if(ok) cout << "YES" << endl; else cout << "NO" << endl;}


const ll INF=1e18;
const int mx=200005;

int main(){
    //オーバーフローは大丈夫ですか？？
    cin.tie(0);ios::sync_with_stdio(false);
    int m;
    cin>>m;
    V<string> s(2);
    cin>>s[0]>>s[1];
    V<V<string>> t(m,V<string>(2));
    rep(i,m)rep(j,2)cin>>t[i][j];
    rep(i,26){
        rep(j,26){
            int ok=1;
            int f=0,g=0;
            rep(k,s[0].size()){
                if(s[0][k]==(char)(i+'a')) f=1;
            }
            rep(k,s[1].size()){
                if(s[1][k]==(char)(j+'a')) g=1;
            }
            if((f&g)==0) continue;
            int cnt=0;
            rep(l,m){
                f=0;g=0;
                rep(k,t[l][0].size()){
                    if(t[l][0][k]==(char)(i+'a')) f=1;
                }
                rep(k,t[l][1].size()){
                    if(t[l][1][k]==(char)(j+'a')) g=1;
                }
                if((f&g)==1){
                    cnt++;
                }
            }
            if(cnt==0){
                cout<<"Yes"<<endl;
                cout<<(char)(i+'a');
                cout<<(char)(j+'a')<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}
accuracy: 1
time_ms: 440
memory_kb: 5148
final_rank: 19

code_snippet: #include <iostream>
#include <string>
#include <vector>
using namespace std;

bool isIn(char c, string s)
{
    int ii;
    int size = s.size();
    for(ii=0; ii<size; ii++)
        if(c==s[ii])
            return true;
    return false;
}

int main()
{
    int i, ans=0;
    int m; cin >> m;
    string s1, s2; cin >> s1 >> s2;
    vector<string> t1(m), t2(m);
    for(i=0; i<m; i++)
        cin >> t1[i] >>t2[i];

    char left='a', right='a';
    while(1)
    {
        if(isIn(left, s1)&&isIn(right, s2)) //ある
        {
            bool isexist = false;
            for(i=0; i<m; i++)
                if(isIn(left, t1[i])&&isIn(right, t2[i])) //ある
                    isexist = true;
            if(!isexist)
            {
                ans=1;
                break;
            }
        }

        if(ans)
            break;
        else if(left=='z'&&right=='z')
            break;
        else if(right!='z')
            right++;
        else
        {
            left++;
            right='a';
        }
    }

    if(ans)
        cout << "Yes" << '\n' << left << right << '\n';
    else
        cout << "No" << '\n';

    return 0;   
}
accuracy: 1
time_ms: 50
memory_kb: 5620
final_rank: 14

code_snippet: #include <bits/stdc++.h>
using namespace std;
int main(){
    int m;cin>>m;
    string s1,s2;cin>>s1>>s2;
    string t1,t2;
    sort(s1.begin(),s1.end());
    s1.erase(unique(s1.begin(),s1.end()),s1.end());//重複削除
    sort(s2.begin(),s2.end());
    s2.erase(unique(s2.begin(),s2.end()),s2.end());
    //cout<<s1<<" "<<s2<<'\n';
    string make;
    vector<string> d(0);
    for(int i=0;i<s1.size();i++){
        for(int j=0;j<s2.size();j++){
            make={s1.at(i),s2.at(j)};
            d.push_back(make);
        }
    }
    /*for(int i=0;i<d.size();i++){
        cout<<d.at(i)<<endl;
    }*/
    vector<string> e(0);
    for(int i=0;i<m;i++){
        cin>>t1>>t2;
        sort(t1.begin(),t1.end());
        t1.erase(unique(t1.begin(),t1.end()),t1.end());
        sort(t2.begin(),t2.end());
        t2.erase(unique(t2.begin(),t2.end()),t2.end());
        //cout<<t1<<" "<<t2<<'\n';
        for(int j=0;j<t1.size();j++){
            for(int k=0;k<t2.size();k++){
                make={t1.at(j),t2.at(k)};
                e.push_back(make);
            }
        }
    }
    sort(e.begin(),e.end());
    e.erase(unique(e.begin(),e.end()),e.end());
    for(int i=0;i<d.size();i++){
        if(binary_search(e.begin(),e.end(),d.at(i))==false){
            cout<<"Yes\n";
            cout<<d.at(i)<<'\n';
            return 0;
        }
    }
    cout<<"No"<<endl;






    /*int m;cin>>m;
    string s1,s2;cin>>s1>>s2;
    string t1,t2;
    sort(s1.begin(),s1.end());
    s1.erase(unique(s1.begin(),s1.end()),s1.end());
    sort(s2.begin(),s2.end());
    s2.erase(unique(s2.begin(),s2.end()),s2.end());
    string make;
    vector<string> d(0);
    for(int i=0;i<s1.size();i++){
        for(int j=0;j<s2.size();j++){
            make={s1.at(i),s2.at(j)};
            d.push_back(make);
        }
    }
    sort(d.begin(),d.end());
    vector<string> e(0);
    for(int i=0;i<m;i++){
        cin>>t1>>t2;
        sort(t1.begin(),t1.end());
        t1.erase(unique(t1.begin(),t1.end()),t1.end());
        sort(t2.begin(),t2.end());
        t2.erase(unique(t2.begin(),t2.end()),t2.end());
        for(int j=0;j<t1.size();j++){
            for(int k=0;k<t2.size();k++){
                make={t1.at(j),t2.at(k)};
                e.push_back(make);
            }
        }
    }
    sort(e.begin(),e.end());
    e.erase(unique(e.begin(),e.end()),e.end());
    for(long long i=0;i<d.size();i++){
        if(binary_search(e.begin(),e.end(),d.at(i))==false){
            cout<<"Yes\n";
            cout<<d.at(i)<<'\n';
            return 0;
        }
    }
    cout<<"No\n";*/
}
accuracy: 1
time_ms: 50
memory_kb: 9016
final_rank: 18

code_snippet: #include <bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int M;
    cin >> M;
    string S1, S2;
    cin >> S1 >> S2;
    vector<string> T1(M), T2(M);
    for (int i = 0; i < M; i++) {
        cin >> T1[i] >> T2[i];
    }
    set<string> SS, TS;
    set<char> a, b;
    for (int i = 0; i < (int)(S1.size()); i++) {
        a.insert(S1[i]);
    }
    for (int i = 0; i < (int)(S2.size()); i++) {
        b.insert(S2[i]);
    }
    for (auto x : a) {
        for (auto y : b) {
            string U;
            U += x;
            U += y;
            SS.insert(U);
        }
    }
    /**
    for (int i = 0; i < (int)(S1.size()); i++) {
        for (int j = 0; j < (int)(S2.size()); j++) {
            string U;
            U += S1[i];
            U += S2[j];
            SS.insert(U);
        }
    }
    **/
    for (int i = 0; i < M; i++) {
        set<char> a, b;
        for (int j = 0; j < (int)(T1[i].size()); j++) {
            a.insert(T1[i][j]);
        }
        for (int j = 0; j < (int)(T2[i].size()); j++) {
            b.insert(T2[i][j]);
        }
        for (auto x : a) {
            for (auto y : b) {
                string U;
                U += x;
                U += y;
                TS.insert(U);
            }
        }
    }
    /**
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < (int)(T1[i].size()); j++) {
            for (int k = 0; k < (int)(T2[i].size()); k++) {
                string U;
                U += T1[i][j];
                U += T2[i][k];
                TS.insert(U);
            }
        }
    }
    **/
    vector<string> ans;
    for (auto X : SS) {
        if (!TS.count(X)) {
            ans.push_back(X);
        }
    }
    sort(ans.begin(), ans.end());
    if (ans.empty()) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
        cout << ans[0] << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 5472
final_rank: 13