#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
map<pair<int, int>, int> ex;
while(cin>>n && n!=0)
{
ex.clear();
int a,b;
for(int i=0;i<n;i++)
{
cin>>a>>b;
ex[make_pair(a,b)]++;
}
bool ans=true;
for(auto x:ex)
{
pair<int, int> p2=make_pair(x.first.second, x.first.first);
if(x.second!=ex[p2])
{
ans=false;
break;
}
}
printf("%s\n",ans?"YES":"NO");
}
}
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
set<string> words;
string word, left, right;
while(cin>>word) words.insert(word);
for(auto x:words)
{
for(int i=0;i<x.size();i++)
{
left.assign(x, 0, i);
if(words.count(left))
{
right.assign(x,i,x.size());
if(words.count(right))
{
cout<<x<<endl;
break;
}
}
}
}
}