#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int n;
vector<pair<int,int>> ab;
int nab = 0;

bool dfs(int sti,int tab){
    bool ret = false;
  //  cout<<sti<<endl;
    if(sti>=2*n+1){
        if(tab==nab)return true;
        else{
            return false;
        }
    }

    for(int c = 1;c+sti<=2*n;c++){
        ll ttab = tab;

       int nextsti = sti+c*2;
       if(nextsti>2*n+1){
           ret = false;
           break;
       }


       bool ok = true;
       for(int i=0;i<c;i++){
           bool cs = false;
           int noru = i+sti;
           int ori = i+sti+c;
           rep(j,n){
               if(ab[j].first==noru){
                   if(ab[j].second==-1||ab[j].second==ori){
                       cs=true;
                   }else{
                       ok=false;
                   }
               }else if(ab[j].second == ori){
                   if(ab[j].first==-1||ab[j].first==noru){
                       cs=true;
                   }else{
                       ok=false;
                   }
               }else if(ab[j].first==ori||ab[j].second==noru){
                   ok = false;
               }
           }
           if(!cs)ttab++;
       }

        if(ok){
            bool s = dfs(nextsti,ttab);
            if(s==true){ret = true;break;}
            else ret = false;
        }else{
             ret = false;
        }
    }
    //cout<<"ret"<<ret<<endl;

    return ret;

}
int main(){
    cin>>n;
    set<int> f;
    rep(i,n){
        int a,b;
        cin>>a>>b;
        ab.push_back({a,b});
        if(a!=-1){
            if(f.find(a)!=f.end()){
                cout<<"No"<<endl;
                return 0;
            }else{
                f.insert(a);
            }
        }
        if(b!=-1){
            if(f.find(b)!=f.end()){
                cout<<"No"<<endl;
                return 0;
            }else{
                f.insert(b);
            }
        }

        if(a!=-1&&b!=-1&&a>=b){
            cout<<"No"<<endl;
            return 0;
        }

        if(a==-1&&b==-1)nab++;

    }
     bool ans = dfs(1,0);

    if(ans){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define x first
#define y second
#define FOR(i, m, n) for (ll i(m); i < n; i++)
#define DWN(i, m, n) for (ll i(m); i >= n; i--)
#define REP(i, n) FOR(i, 0, n)
#define DW(i, n) DWN(i, n, 0)
#define F(n) REP(i, n)
#define FF(n) REP(j, n)
#define D(n) DW(i, n)
#define DD(n) DW(j, n)
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using tll = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vpll = vector<pll>;
using vtll = vector<tll>;
using gr = vector<vll>;
using wgr = vector<vpll>;
void add_edge(gr&g,ll x, ll y){ g[x].pb(y);g[y].pb(x); }
void add_edge(wgr&g,ll x, ll y, ll z){ g[x].eb(y,z);g[y].eb(x,z); }
struct d_ {
    template<typename T> d_& operator,(const T& x) {
        cerr << ' ' <<  x; return *this;}
    template<typename T,typename U> d_& operator,(const pair<T,U>& x) {
        cerr << ' ' <<  x.x << ',' << x.y; return *this;}
    template<typename T> d_& operator,(const vector<T>& x) {
        for(auto x: x) cerr << ' ' <<  x; return *this;}
} d_t;
#define dbg(args ...) { d_t,"|",__LINE__,"|",":",args,"\n"; }
#define deb(X ...) dbg(#X, "=", X);
#define EPS (1e-10)
#define INF (1LL<<61)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

const ll N = 207;
ll n;
ll A[N];
ll B[N];
ll Len[N];
ll in[N],out[N];

void end() {
    cout << "No" << endl;
    exit(0);
}

bool solve(ll i) {
    if(i==n) return 1;
    ll len = 1;
    while(i+2*len<=n) {
        bool ok = 1;
        FOR(k,i,i+2*len) {
            ok &= Len[k]==-1 || Len[k]==len;
            if(in[k]) ok &= k-i<len;
            if(out[k]) ok &= k-i>=len;
        }
        FOR(k,i,i+len) {
            if(in[k] && out[k+len]) {
                ok &= in[k]==out[k+len];
            }
        }
        if(ok && solve(i+2*len)) return 1;
        len++;
    }
    return 0;
}

int main(void) {
    ios_base::sync_with_stdio(false);
    CL(Len,-1);
    cin >> n;
    F(n) {
        cin >> A[i] >> B[i];
        if(~A[i]) A[i]--;
        if(~B[i]) B[i]--;
    }
    bool ok = 1;
    set<ll> vals;
    F(n) {
        if(~A[i] && ~B[i]) {
            ok &= A[i]<B[i]; 
            if(ok) FOR(k,A[i],B[i]+1) Len[k]=B[i]-A[i];
        }
        if(~A[i]) { in[A[i]]=i+1; ok&=!vals.count(A[i]); vals.insert(A[i]); }
        if(~B[i]) { out[B[i]]=i+1; ok&=!vals.count(B[i]); vals.insert(B[i]); }
    }
    n*=2;
    if(!ok) end();
    ok &= solve(0);
    if(!ok) end();
    cout << "Yes" <<endl;
    return 0;
}
