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

int main(){
#ifdef _DEBUG
	//freopen("_in" , "r", stdin );
	//freopen("_out", "w", stdout);
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	string s[3]; cin >> s[0] >> s[1] >> s[2];
	int i = 0;
	for(;;) {
		if (!s[i].size()) break;
		int t;
		if (s[i][0] == 'a') t = 0;
		if (s[i][0] == 'b') t = 1;
		if (s[i][0] == 'c') t = 2;
		s[i].erase(0, 1);
		i = t;
	}
	if (i == 0) cout << 'A';
	if (i == 1) cout << 'B';
	if (i == 2) cout << 'C';
	cout << '\n';
}

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

int main(){
  int N;
  cin>>N;
  int A[N];
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  bool ans=true;
  sort(A,A+N);
  for(int i=0;i<N-1;i++){
    if(A[i]==A[i+1]){
      ans =false;
      break;
    }
  }
  if(ans){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}