sicily 1021. Couples
#include<iostream>
#include<stack>
#include<map>
#include<stdio.h>
using namespace std;
int main()
{
int n, m1,m2,k;
while(scanf("%d",&n)&&n)
{
map<int,int> m;
stack<int> c;
for(int i=0;i<n;i++)
{
scanf("%d%d",&m1,&m2);
m[m1]=m2;
m[m2]=m1;
}
for(k=1;k<=2*n;k++)
{
if(!c.empty()&&m[k]==c.top())
c.pop();
else
c.push(k);
}
if(c.empty())
printf("Yes\n");
else
printf("No\n");
}
return 0;
}