> File Name: 5820_2.cpp
> Author: jiangyuzhu
> Mail: 834138558@qq.com
> Created Time: 2016/8/23 13:45:44
************************************************************************/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
const int maxn = 5e5 + 5, maxm = 5e4 + 1;
int T[maxm * 8];
int M, n;
void add(int a, int x)
{
T[a += M] = x;
for(a >>= 1;a;a >>= 1){
T[a] = max(T[a << 1], T[a << 1|1]);
}
}
int query(int l, int r)
{
l = l + M - 1, r = r + M + 1;
int ans = 0;
for(; l^r^1; l >>= 1, r >>= 1){
if(~l & 1) ans = max(T[l ^ 1], ans);
if(r & 1) ans = max(T[r ^ 1], ans);
}
return ans;
}
vector<int>v[maxm];
int main (void)
{
for(M = 1; M <= maxm + 1; M <<= 1);
while(~scanf("%d", &n) && n){
int x, y;
for(int i = 0; i < maxm; i++) v[i].clear();
for(int i = 0; i < n; i++){
scanf("%d%d", &x, &y);
v[x].push_back(y);
}
for(int i = 1; i < maxm; i++){
if(!v[i].size()) continue;
sort(v[i].begin(), v[i].end());
v[i].erase(unique(v[i].begin(), v[i].end()), v[i].end());
}
int up, down;
bool flag = true;
memset(T, 0, sizeof(T));
for(int i = 1; i < maxm; i++){
if(!v[i].size()) continue;
int sz = v[i].size();
for(int j = 0; j < sz; j++){
up = j ? v[i][j - 1]:0;
down = j == v[i].size() - 1? maxm + 1:v[i][j + 1];
if(query(up + 1, down - 1) > T[v[i][j] + M]) flag = false;
if(!flag) break;
}
if(!flag) break;
for(int j = 0; j < sz; j++){
add(v[i][j], i);
}
}
flag?puts("YES"):puts("NO");
}
return 0;
}