// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
const ll MAX = 210,INF=1e15;
vector<ll> a(MAX),b(MAX);
ll joker = 0;
ll n;
vector<vector<ll>> dp(MAX,vector<ll>(MAX,-1));
ll solve(ll l,ll r){
  if(dp[l][r]!=-1) return dp[l][r];
  ll res;
  ll size = r-l+1;
    res = 0;
    vector<ll> cnt(MAX,0);
    for(int i=0;i<n;i++){
      if(a[i]==b[i]&&a[i]==-1) continue;
      if(l<=a[i]&&a[i]<=r){
        cnt[a[i]]++;
        ll idx;
        if(b[i]==-1){
          idx = min(MAX-1,a[i]+size/2);
        }else if(b[i]-a[i]==size/2){
          idx = b[i];
        }else{
          res = INF;
          break;
        }
        cnt[idx]++;
      }else if(l<=b[i]&&b[i]<=r){
        cnt[b[i]]++;
        ll idx;
        if(a[i]==-1){
          idx = max(0ll,b[i]-size/2);
        }else if(b[i]-a[i]==size/2){
          idx = a[i];
        }else{
          res = INF;
          break;
        }
        cnt[idx]++;
      }
    }
    for(int i=0;i<MAX;i++){
      if((l>i||i>r)&&cnt[i]){
        res = INF;
        break;
      }
      if(cnt[i]>=2){
        res = INF;
        break;
      }
    }
    for(int i=l;i<l+size/2;i++){
      if((cnt[i]+cnt[i+size/2])==0){
        res++;
      }
    }
    for(int i=l+2;i<r;i++){
      res = min(res,solve(l,i-1)+solve(i,r));
    }
  return dp[l][r] = res;
}
signed main(){
  init_io();
  cin >> n;
  bool can = true;
  map<ll,ll> mp;
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
    if(a[i]==b[i]&&a[i]==-1){
      joker++;
    }
    mp[a[i]]++;
    mp[b[i]]++;
    if(a[i]!=-1&&b[i]!=-1&&a[i] >= b[i]){
      can = false;
    }
  }
  for(auto [x,y]:mp){
    if(x==-1) continue;
    if(y!=1){
      can = false;
      break;
    }
  }
  if(!can){
    cout <<"No"<<endl;
    return 0;
  }
  ll v = solve(1,n*2);
  if(v<=joker){
    cout << "Yes"<<endl;
  }else{
    cout <<"No"<<endl;
  }
}

#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
namespace atcoder {}
using namespace atcoder;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2> bool chmin(T1 &l, const T2 &r);
template <class T1, class T2> bool chmax(T1 &l, const T2 &r);
#define int long long int

void solve(long long N, std::vector<long long> A, std::vector<long long> B,
           std::vector<long long> C, std::vector<long long> D,
           std::vector<long long> E) {
  int up = 2e9, low = 0;
  auto check = [&](int there) {
    int dp[3001][1 << 5][4] = {};
    dp[0][0][0] = 1;
    for (int i = 0; i < N; i++) {
      int mask = 0;
      if (A[i] >= there)
        mask |= 1;
      if (B[i] >= there)
        mask |= 2;
      if (C[i] >= there)
        mask |= 4;
      if (D[i] >= there)
        mask |= 8;
      if (E[i] >= there)
        mask |= 16;

      for (int j = 0; j < 1 << 5; j++) {
        for (int k = 0; k < 4; k++) {
          if (k != 3)
            dp[i + 1][j | mask][k + 1] |= dp[i][j][k];
          dp[i + 1][j][k] |= dp[i][j][k];
        }
      }
    }
    return dp[N][31][3];
  };
  while (up - low > 1) {
    int mid = (up + low) / 2;
    (check(mid) ? low : up) = mid;
  }
  cout << low << endl;
}

signed main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  std::vector<long long> B(N);
  std::vector<long long> C(N);
  std::vector<long long> D(N);
  std::vector<long long> E(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
    scanf("%lld", &B[i]);
    scanf("%lld", &C[i]);
    scanf("%lld", &D[i]);
    scanf("%lld", &E[i]);
  }
  solve(N, std::move(A), std::move(B), std::move(C), std::move(D),
        std::move(E));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2> bool chmin(T1 &l, const T2 &r) {
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2> bool chmax(T1 &l, const T2 &r) {
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2> void vadd(vector<T1> &v, T2 x) {
  for (auto &s : v)
    s += T2(x);
}
