#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1<<30;
const ll inf_l = 1LL<<61;
const int MAX = 1e5;

int n;
vint both;
vector<bool> is_end;
vector<bool> is_start;

map<P,bool> memo_1;
map<int,bool> memo_2;

bool dfs(int start) {
    if (start == 2 * n) return true;
    if (memo_2.count(start)) return memo_2[start];
    bool res = false;
    for (int len = 1; start + 2 * len - 1 < 2 * n; len++) {
        bool ok = true;
        if (memo_1.count(P(start, len))) ok = memo_1[P(start, len)];
        else {
            for (int s = start; s < start + len; s++) {
                int t = s + len;
                if (both[s] != -1) {
                    if (both[s] != t) ok = false;
                } else {
                    if (is_end[s] || is_start[t]) ok = false;
                    if (is_end[t] && is_start[s]) ok = false;
                }
            }
            memo_1[P(start, len)] = ok;
        }
        if (ok) res |= dfs(start + 2 * len);
    }
    return memo_2[start] = res;

}

int main() {
    cin >> n;
    both.assign(2 * n, -1);
    is_end.assign(2 * n, false);
    is_start.assign(2 * n, false);
    set<int> used;
    rep(i,n) {
        int a, b; cin >> a >> b;
        if (used.count(a) && a != -1) {
            cout << "No" << endl;
            return 0;
        }
        if (used.count(b) && b != -1) {
            cout << "No" << endl;
            return 0;
        }
        used.insert(a); used.insert(b);
        if (a != -1 && b != -1) both[--a] = --b;
        else if (a == -1 && b == -1) continue;
        else if (a == -1) is_end[--b] = true;
        else if (b == -1) is_start[--a] = true;
    }
    if (dfs(0)) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 3e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n;
int a[MAXN], b[MAXN], dur[MAXN], dp[MAXN], g[MAXN];
int dd(int i){
    if(i > 2*n) return 1;
    if(dp[i] != -1)
        return dp[i];
    dp[i] = 0;
    for(int j = 1; i + 2*j <= 2*n + 1; j++){
        bool can = 1;
        for(int c = i; c < i + j; c++){
            if(dur[c] == 2 || (dur[c] == 1 && dur[c + j] != 0) || (dur[c] == 3 && g[c] != c + j)){
                can = 0;
                break;
            }
        }
        for(int c = i + j; c < i + 2*j; c++){
            if(dur[c] == 1 || (dur[c] == 2 && dur[c - j] != 0) || (dur[c] == 3 && g[c] != c - j)){
                can = 0;
            }
            if(!can) break;
        }
        dp[i] |= (can && dd(i + 2*j));
    }
    return dp[i];
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);

    #ifdef Local
        freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/int.txt","r",stdin);
        freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/out.txt","w",stdout);
    #endif

    cin>>n;
    memset(dp, -1, sizeof(dp));
    for(int i = 0; i < n; i++){
        cin>>a[i]>>b[i];
        if(a[i] == -1 && b[i] == -1){
            continue;
        }else if(a[i] == -1){
            if(dur[b[i]] != 0){
                cout<<"No"<<endl;
                return 0;
            }  
            dur[b[i]] = 2;
        }else if(b[i] == -1){
            if(dur[a[i]] != 0){
                cout<<"No"<<endl;
                return 0;
            }
            dur[a[i]] = 1;
        }else{
            if(dur[a[i]] != 0 || dur[b[i]] != 0){
                cout<<"No"<<endl;
                return 0;
            }
            dur[a[i]] = 3;
            dur[b[i]] = 3;
            g[b[i]] = a[i];
            g[a[i]] = b[i];
            if(b[i] <= a[i]){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }

    if(dd(1))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}