#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int pos[n],val[n];
for(int i=0; i<n; i++)
cin>>pos[i]>>val[i];
int freq[200001]= {};
for(int i=0; i<n; i++)
{
if(freq[val[i]]==0)freq[val[i]]=pos[i];
else if(freq[val[i]]>pos[i])
{
cout<<"NO";
return 0;
}
else freq[val[i]]=pos[i];
}
cout<<"YES";
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkKewogICAgaW50IG47CiAgICBjaW4+Pm47CiAgICBpbnQgcG9zW25dLHZhbFtuXTsKICAgIGZvcihpbnQgaT0wOyBpPG47IGkrKykKICAgICAgICBjaW4+PnBvc1tpXT4+dmFsW2ldOwogICAgICAgIAogICAgaW50IGZyZXFbMjAwMDAxXT0ge307CiAgICAKICAgIGZvcihpbnQgaT0wOyBpPG47IGkrKykKICAgIHsKICAgICAgICBpZihmcmVxW3ZhbFtpXV09PTApZnJlcVt2YWxbaV1dPXBvc1tpXTsKICAgICAgICBlbHNlIGlmKGZyZXFbdmFsW2ldXT5wb3NbaV0pCiAgICAgICAgewogICAgICAgICAgICBjb3V0PDwiTk8iOwogICAgICAgICAgICByZXR1cm4gMDsKICAgICAgICB9CiAgICAgICAgZWxzZSBmcmVxW3ZhbFtpXV09cG9zW2ldOwogICAgfQogICAgY291dDw8IllFUyI7CiAgICByZXR1cm4gMDsKfQo=