#include <bits/stdc++.h>
// #include <atcoder/all>

using namespace std;
// using namespace atcoder;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x) REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n) REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x) REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m) REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw`(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
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;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 998244353;
// using mint = static_modint<MOD>;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair



bool DEBUG = 0;
template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}


void solve(){
  int N; cin>>N;
  vector<int> a(N),b(N);
  int M = N*2;
  vector<int> tp(M,0),com(M,-1);

  REP(i,N){
    cin >> a[i] >> b[i];
    if(a[i]!=-1){
      --a[i];
      if(tp[ a[i] ]!=0){ cout << Linn; return; }
      tp[ a[i] ] = i+1;
    }
    if(b[i]!=-1){
      --b[i];
      if(tp[ b[i] ]!=0 ){cout << Linn; return;}
      tp[ b[i] ] = -(i+1);
    }
    if(a[i]!=-1 && b[i]!=-1){
      com[ a[i] ] = b[i];
      com[ b[i] ] = a[i];
    }
  }
  dprint("---78----");

  vector<bool> dp(M+1,false);
  dp[0] = true;
  REP(i,M){
    if(!dp[i]){continue;}
    dprint("--");

    for(int j=i+1;j<M;++j){
      int w = j - i + 1;
      if(w%2){continue;}
      w /= 2;
      bool ok = true;
      vector<bool> exist(N,false);

      REP(k,w){
        int start = i+k;
        int stop = i+k+w;
        if(com[start] != -1 && !(i<=com[start] && com[start]<=j) ){
          ok = false;
          break;
        }
        dprint("r1");
        if(com[stop] != -1 && !(i<=com[stop] && com[stop]<=j)){
          ok = false;
          break;
        }
        dprint("r2");
        
        if(tp[start] != 0 && tp[stop] != 0){
          if( tp[start]<0 || tp[start]+tp[stop] != 0){
            ok = false;
            break;
          }
        }
        dprint("r3");
        if(tp[start]<0 || tp[stop]>0){
          ok = false;
          break;
        }
        dprint("r4");
        if(tp[start] != 0){
          int temp = tp[start]-1;
          if(exist[temp]){
            ok = false;
            break;
          }
          exist[temp] = 1;
        }
        dprint("r5");
      }
      if(ok){
        dp[j+1] = 1;
      }
    }
  }
  dprint("---130---");
  REP(i,M+1){
    dprint(dp[i]);
  }
  if(dp[M]){ cout << Liny; }
  else{ cout << Linn; }
  return;
}

int main(int argc, char *argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG = 1;}
  solve();
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
    string sep = " ";
    if(v.size()) os << v[0];
    for(int i=1; i<v.size(); i++) os << sep << v[i];
    return os;
}

template<typename T>
istream& operator>>(istream &is, vector<T> &v){
    for(int i=0; i<v.size(); i++) is >> v[i];
    return is;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
    cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
    ios_base::sync_with_stdio(false);
    cout << setprecision(20) << fixed;

    int n; cin >> n;
    vector<int> s(2*n), d(2*n);
    for(int i=0; i<n; i++){
        int a, b; cin >> a >> b;
        a--; b--;
        if(a>=0&&b>=0){
            if(b<=a||s[a]!=0||s[b]!=0) {
                cout << "No" << endl;
                return 0;
            }
            s[a] = (i+1);
            s[b] = -(i+1);
            d[a] = b-a;
            d[b] = a-b;
        } else if(a>=0){
            if(s[a]!=0){
                cout << "No" << endl;
                return 0;
            }
            s[a] = i+1;
        } else if(b>=0){
            if(s[b]!=0){
                cout << "No" << endl;
                return 0;
            }
            s[b] = -(i+1);
        }
    }

    vector<bool> dp(2*n+1);

    dp[0] = true;

    for(int i=0; i<2*n; i++){
        if(!dp[i]) continue;
        for(int j=i+1; j<2*n; j+=2){
            int w = (j-i+1)/2;
            bool ok = true;
            for(int k=0; k<w; k++){
                int p = i+k, q = i+w+k;
                if(d[p]!=0&&p+d[p]!=q) ok = false;
                if(d[q]!=0&&q+d[q]!=p) ok = false;

                if(s[p]!=0&&s[q]!=0&&s[p]+s[q]!=0) ok = false;
                if(s[p]<0 || 0<s[q]) ok = false;

                // if(s[p]<0) ok = false;
                // if(d[p]!=0&&d[p]!=w) ok = false;

                // if(s[q]>0) ok = false;
                // if(d[p]!=0&&d[q]!=-w) ok = false;
            }
            if(ok) dp[j+1] = true;
        }
    }

    cout << (dp[2*n]?"Yes":"No") << endl;

    return 0;
}