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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

vector<bool> used;
vector<int> dir; // left==0, right==1, other -1
vector<int> p;

bool connect(int i, int j){
    if(used[i]==false && used[j]==false) return true;
    else if(used[i]==true && used[j]==false){
        if(p[i]==-1 && dir[i]==1) return true;
        else return false;
    }
    else if(used[i]==false && used[j]==true){
        if(p[j]==-1 && dir[j]==0) return true;
        else return false;
    }
    else{
        if(p[i]==j && p[j]==i) return true;
        else return false;
    }
}

int dp[300][300];

int rec(int l, int r){
    if(dp[l][r] != -1) return dp[l][r];
    if(r-l<2) return dp[l][r] = 0;

    int len = (r-l)/2;
    bool flag = true;
    REP(i,len){
        if(!connect(l+i,l+i+len)){
            flag = false;
            break;
        }
    }
    int ret = 0;
    if(flag) ret = 1;

    for(int m=l+2; m<=r-2; m+=2){
        if(rec(l,m)==1 && rec(m,r)==1) ret = 1;
    }
    return dp[l][r] = ret;
}

void Main(){
    int N; cin >> N;
    VI A(N), B(N);
    REP(i,N){
        cin >> A[i] >> B[i];
        if(A[i]>0) A[i]--;
        if(B[i]>0) B[i]--;
    }
    REP(i,N){
        if(A[i]==2*N-1 || B[i]==0){
            cout << "No" << en;
            return;
        }
        if(A[i]!=-1 && B[i] !=-1 && B[i]<=A[i]){
            cout << "No" << en;
            return;
        }
    }
    VI cnt(2*N,0);
    REP(i,N){
        if(A[i]!=-1){
            cnt[A[i]]++;
            if(cnt[A[i]]>1){
                cout << "No" << en;
                return;
            }
        }
        if(B[i]!=-1){
            cnt[B[i]]++;
            if(cnt[B[i]]>1){
                cout << "No" << en;
                return;
            }
        }
    }

    used.assign(2*N,false); dir.assign(2*N,-1); p.assign(2*N,-1);
    REP(i,N){
        if(A[i]!=-1){
            used[A[i]] = true;
            dir[A[i]] = 1;
            p[A[i]] = B[i];
        }
        if(B[i]!=-1){
            used[B[i]] = true;
            dir[B[i]] = 0;
            p[B[i]] = A[i];
        }
    }
    REP(i,300)REP(j,300) dp[i][j] = -1;
    int ans = rec(0,2*N);
    cout << (ans==1 ? "Yes" : "No") << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,a[100005],vis[100005],f[100005];
bool check(int x,int y)
{
	if(vis[x]==2||vis[y]==1) return 0;
	if(vis[x]&&a[x]&&a[x]!=y) return 0;
	if(vis[y]&&a[y]&&a[y]!=x) return 0;
	if(vis[y]&&vis[x]&&!a[x]) return 0;
	return 1;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		if((x!=-1&&vis[x])||(y!=-1&&vis[y]))
		{
			printf("No\n");
			return 0;
		}
		if(x!=-1&&y!=-1)
		{
			if(x>=y)
			{
				printf("No\n");
				return 0;
			}
			a[x]=y,a[y]=x;
		}
		if(x!=-1) vis[x]=1;
		if(y!=-1) vis[y]=2;
	}
	f[0]=1;
	for(int i=1;i<=2*n;i++)
	{
		for(int j=i-2;j>=0;j-=2)
			if(f[j])
			{
				int fl=1;
				for(int l=j+1,r=j+(i-j)/2+1;r<=i;l++,r++)
					if(!check(l,r))
					{
						fl=0;
						break;
					}
				if(fl)
				{
					f[i]=1;
					break;
				}
			}
	}
	if(f[2*n]) printf("Yes\n");
	else printf("No\n");
	return 0;
}