#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> used(2 * N);
  auto out = []() {
    cout << "No" << endl;
    exit(0);
  };
  REP(i, N) {
    int A, B;
    cin >> A >> B;
    if (A != -1 && B != -1 && A >= B) {
      out();
    }
    if (A != -1) {
      if (used[A - 1] != 0) out();
      used[A - 1] = i + 1;
    }
    if (B != -1) {
      if (used[B - 1] != 0) out();
      used[B - 1] = -(i + 1);
    }
  }
  vector<bool> dp(N + 1);
  dp[0] = 1;
  FOR(i, 1, N + 1) {
    REP(j, i)
    if (dp[j]) {
      bool ng = 0;
      int width = i - j;
      REP(k, width) {
        int a = used[2 * j + k], b = used[2 * j + k + width];
        ng |= (a < 0);
        ng |= (b > 0);
        ng |= (a > 0 && b < 0 && b != -a);
      }
      if (!ng) {
        dp[i] = 1;
        break;
      }
    }
  }
  cout << (dp[N] ? "Yes" : "No") << endl;
  return 0;
}
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
#include<set>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
    if(vec_n==-1)vec_n=vec_s.size();
    for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
    if(vec_n==-1)vec_n=vec_s.size();
    for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int t[220][2];
int p[220][2];

bool solve(){
    int n,m;
    int i,j,k;
    int a,b,c;
    cin>>n;
    memset(t,-1,sizeof(t));
    set<P> s1;
    for(i=0;i<n;i++){
        cin>>a>>b;
        if(a!=-1){
            a--;
            if(t[a][0]!=-1)return false;
            t[a][0]=i,t[a][1]=0;
        }
        if(b!=-1){
            b--;
            if(t[b][0]!=-1)return false;
            t[b][0]=i,t[b][1]=1;
        }
        p[i][0]=a,p[i][1]=b;
        if(a!=-1 && b!=-1 && a>=b)return false;
    }
    vector<char> good(2*n+10,0);
    good[2*n]=1;
    for(i=2*n-1;i>=0;i--){
        for(j=1;i+2*j<=2*n;j++){
            if(!good[i+2*j])continue;
            for(k=0;k<j;k++){
                a=t[i+k][0];
                if(a==-1)a=t[i+j+k][0];
                else if(t[i+j+k][0]!=-1 && a!=t[i+j+k][0])break;
                if(a==-1)continue;
                if(p[a][0]!=-1 && p[a][0]!=i+k)break;
                if(p[a][1]!=-1 && p[a][1]!=i+j+k)break;
            }
            if(k==j){
                good[i]=1;
                break;
            }
        }
    }
    return good[0];
}


int main(){
    if(solve())cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}