#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N=111;
int a[N],b[N],u[N+N];
int dp[N][N];
void no(){
    cout<<"No\n";
    exit(0);
}
int32_t main(){
    int f=0;
    int n;
    cin>>n;
    for(int i=1;i<=n;++i){
        cin>>a[i]>>b[i];
        if(a[i]!=-1&&b[i]!=-1&&a[i]>=b[i])no();
        if(a[i]!=-1&&u[a[i]])no();
        if(b[i]!=-1&&u[b[i]])no();
        if(a[i]!=-1)u[a[i]]=1;
        if(b[i]!=-1)u[b[i]]=1;
        if(a[i]==-1&&b[i]==-1)f++;
    }
    dp[0][0]=1;
    for(int i=1;i<=n;++i){
        for(int c=0;c<=min(i,f);c++){
            forn(j,i){
                dbg(j);
                memset(u,0,sizeof u);
                int d=i-j,ok=1;
                for(int k=1;ok&&k<=n;++k){
                    int ak=a[k],bk=b[k];
                    if(ak==bk)continue;//-1
                    if(ak!=-1&&ak<=i+i&&ak>j+j+d)ok=0;
                    if(bk!=-1&&bk<=j+j+d&&bk>j+j)ok=0;
                    dbg(ak,bk);
                    if(ak>i+i)continue;
                    if(bk>i+i)continue;
                    if(ak!=-1&&ak<=j+j)continue;
                    if(bk!=-1&&bk<=j+j)continue;
                    if(ak==-1)ak=bk-d;
                    if(bk==-1)bk=ak+d;
                    if(bk<=j+j+d)ok=0;
                    dbg(k,ok,ak,d,bk);
                    if(ak+d!=bk)ok=0;
                    if(u[ak]||u[bk])ok=0;
                    u[ak]=u[bk]=1;
                }
                int nado=0;
                for(int k=j+j+1;ok&&k<=j+j+d;++k){
                    if(!u[k]&&u[k+d])ok=0;
                    if(u[k]&&!u[k+d])ok=0;
                    dbg(k,ok,nado);
                    if(u[k]&&u[k+d])continue;
                    nado++;
                }
                dbg(ok,nado);
                if(ok&&nado<=c)dp[i][c]|=dp[j][c-nado];
            }
            dbg(i,c,dp[i][c]);
        }
        dbg("====", i+1);
    }
    if(!dp[n][f])no();
    cout<<"Yes\n";
    return 0;
}
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const long long MOD = 1000000007;

ll N, A[201], B[201];
ll L[201], R[201];
bool dp[201], used[201];

signed main(){
    cin >> N;
    REP(i, N) cin >> A[i] >> B[i];
    REP(i, 2 * N) L[i] = R[i] = -1;
    REP(i, N){
        if(A[i] != -1){
            A[i]--;
            if(L[A[i]] != -1 || R[A[i]] != -1){
                PRINT("No");
                return 0;
            } 
            L[A[i]] = i;
        }
        if(B[i] != -1){
            B[i]--;
            if(R[B[i]] != -1 || L[B[i]] != -1){
                PRINT("No");
                return 0;
            }
            R[B[i]] = i;
        }
    }
    dp[0] = true;
    REP(i, 2 * N){
        if(!dp[i]) continue;
        FOR(j, i + 1, 2 * N){
            ll w = j - i + 1;
            if(w & 1) continue;
            w /= 2;
            bool ok = true;
            REP(k, N) used[k] = false;
            REP(k, w){
                ll p = i + k, q = i + w + k;
                if(L[q] != -1 || R[p] != -1) ok = false;
                if(L[p] != -1 && R[q] != -1 && L[p] != R[q]) ok = false;
                if(L[p] != -1){
                    if(used[L[p]]) ok = false;
                    used[L[p]] = true;
                }
                if(R[q] != -1){
                    if(L[p] != R[q] && used[R[q]]) ok = false;
                    used[R[q]] = true;
                }
            }
            if(ok) dp[j + 1] = true;
        }
    }
    if(dp[2 * N]) PRINT("Yes");
    else PRINT("No");
    return 0;
}