#include<cstdio>
using namespace std;
const int maxn = 500000 + 10;
int A[maxn], B[maxn];
int main()
{
int n;
while(scanf("%d", &n) == 1)
{
if(n == 0) break;
int ok = 0;
for(int i = 1; i <= n; i++)
{
scanf("%d", &A[i]);
scanf("%d", &B[i]);
}
for(int i = 1; i <= n; i++)
{
ok = 0;
for(int j = 1; j <= n; j++)
if(B[j] == A[i]) ok = 1;
if(!ok) break;
}
printf("%s", ok ? "YES" : "NO");
}
return 0;
}
是因为没优化(虽然这题无关算法)还是因为啥(样例能过)