#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000;
constexpr ll llINF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
vector<vector<int>>C,sC;
void init_comb(int n,int m){
    C.resize(n+1,vector<int>(m+1,0));
    sC.resize(n+1,vector<int>(m+1,0));
    C[0][0]=1;
    for(int i=1;i<=n;i++){
        C[i][0]=1;
        for(int j=1;j<=m;j++){
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
        }
    }
    rep(i,n+1){
        rep(j,m){
            sC[i][j+1]=(sC[i][j]+C[i][j])%mod;
        }
    }
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int>p(2*n),pa(2*n,-1);
    rep(i,n){
        int a,b;
        cin>>a>>b;
        if(a>=0){
            a--;
            if(p[a]){
                puts("No");
                return 0;
            }
            p[a]=(i+1);
        }
        if(b>=0){
            b--;
            if(p[b]){
                puts("No");
                return 0;
            }
            p[b]=-(i+1);
        }
        if(a>=0&&b>=0){
            if(a>b){
                puts("No");
                return 0;
            }
            pa[a]=b;
            pa[b]=a;
        }
    }
    vector<bool>dp(2*n,false);
    dp[0]=true;
    rep(i,2*n){
        for(int j=i+1;j<2*n;j+=2){
            int t=(j-i+1)/2;
            bool ok=true;
            rep(k,t){
                int x=i+k,y=x+t;
                if(pa[x]>=0&&pa[y]!=x){
                    ok=false;
                }
                if(pa[x]!=y&&pa[y]>=0){
                    ok=false;
                }
                if(p[x]!=0&&p[y]!=0&&p[x]+p[y]!=0){
                    ok=false;
                }
                if(p[x]<0&&p[y]>0){
                    ok=false;
                }
            }
            dp[j+1]=dp[j+1]|(dp[i]&ok);
        }
    }
    cout<<(dp[2*n]?"Yes":"No")<<endl;
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
const int maxn = 204;
bool dp[maxn][maxn];

int l[maxn],r[maxn],vis[maxn];
int w[maxn];


int main()
{
    int n;
    scanf("%d",&n);
    bool ok = true;
    for(int i = 1,a,b;i <= n;++i){
        scanf("%d%d",&a,&b);
        if(a!=-1&&b==-1){
            if(vis[a]){
                ok = false;
            }
            vis[a] = 1;
            l[a] = 1;
        }
        else if(a==-1&&b!=-1){
            if(vis[b]){
                ok = false;
            }
            vis[b] = 1;
            r[b] = 1;
        }
        else if(a!=-1&&b!=-1){
            if(vis[a]||vis[b]||a>=b){
                ok = false;
            }
            vis[a] = vis[b] = 1;
            l[a] = r[b] = 1;
            w[a] = w[b] = b-a;
        }
    }
    if(!ok){
        printf("No\n");
        return 0;
    }
    for(int len = 2;len <= 2*n;len += 2){
        for(int i = 1;i <= 2*n;++i){
            int j = i+len-1;
            if(j > 2*n)break;
            int tmp = len/2;
            bool ok = true;
            for(int k = i;k <= j-tmp;++k){
                if(r[k])ok=0;
                if(l[k]&&w[k]>0){
                    if(w[k]!=tmp)ok=0;
                }
                if(!w[k]&&l[k]&&r[k+tmp])ok=0;
            }
            for(int k = j-tmp+1;k <= j;++k){
                if(l[k])ok=0;
            }
            dp[i][j] |= ok;
            for(int k = i;k < j;++k){
                dp[i][j] |= dp[i][k]&dp[k+1][j];
            }
        }
    }
    if(dp[1][2*n])printf("Yes\n");
    else printf("No\n");
    return 0;
}