#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define MO 1000000007
#define mem(a,s) memset(a,s,sizeof(a))
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define lop(i,s,e) for(int i=s;i<e;i++)
#define lopi(i,s,e) for(int i=s;i>=e;i--)
#define prina(a,n) for(int i=0;i<=n;i++)cout<<a[i]<<" ";cout<<endl; 
#define prin2da(a,n,m) lop(i,1,n){lop(j,1,m)cout<<a[i][j]<<" ";cout<<endl;}
#define atout(v) for(auto x:v) cout<<x<<" ";cout<<endl;
#define atin(v) for(auto &x:v) cin>>x;
#define vl vector<ll >
#define vi vector<int >
#define lb lower_bound
#define ub upper_bound
#define sort(a) sort(a.begin(),a.end())  
#define mp make_pair
#define all(v) v.begin(),v.end() 
#define pll pair<ll,ll>
using namespace std;

bool check(ll l,ll r,vector<vector<ll>> &p,vector<ll> &b) {
	ll n=p.size();
	lop(i,l,r+1) b[i]=0;
	lop(i,0,n) {
		ll x=p[i][0],y=p[i][1];
		if(x!=-1 and y!=-1) {
			if(y<l or x>r) continue;
			if(y-x!=(r-l+1)/2 or b[x]) return false;
			b[x]=1;
		}
		else if(x!=-1 and y==-1) {
			if(x>r or x<l) continue;
			if(x>=(r+l+1)/2 or b[x]) return false;
			b[x]=1;
		}
		else if(x==-1 and y!=-1) {
			if(y<l or y>r) continue;
			x=y-((r-l+1)/2);
			if(y<(r+l+1)/2 or b[x]) return false;
			b[x]=1;
		}
	}
	return true;
}

void solve() {
	ll n;
	cin>>n;
	vector<vector<ll>> p(n,vector<ll>(2,0));
	vector<bool> dp(2*n+1,false);
	vector<ll> b(2*n+1);
	lop(i,0,n) cin>>p[i][0]>>p[i][1];
	dp[0]=true;
	for(int i=0 ; i<(2*n)+1 ; i+=2) {
		for(int j=i+2 ; j<=(2*n)+1 ; j+=2) {
			//cout<<check(i+1,j,p,b)<<endl;
			dp[j]=dp[j]or(dp[i] and check(i+1,j,p,b));
		}
	}
	//atout(dp);
	cout<<((dp[2*n])?"Yes":"No")<<endl;
	return;
}

int main() {
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif

	ll t=1;
	while(t--) {
		solve();
	}

	return 0;
}
#include <bits/stdc++.h>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;
	vector<bool> ju(2*n+1);
	vector<int> a(n),b(n);
	bool res=true;
	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i];
		a[i]--,b[i]--;
		if(a[i]>=0 && ju[a[i]]) res=false;
		if(b[i]>=0 && ju[b[i]]) res=false;
		if(a[i]>=0) ju[a[i]]=true;
		if(b[i]>=0) ju[b[i]]=true;
		
		if(a[i]>=0 && b[i]>=0 && a[i]>=b[i]) res=false;
	}
	if(!res){
		cout << "No" << "\n";
		return 0;
	}
	
	vector<bool> dp(2*n+1);
	dp[2*n]=true;
	
	for(int i=2*n-1;i>=0;i--){
		for(int j=1;j<2*n;j++){
			if((i+2*j)>2*n) continue;
			if(!dp[i+2*j]) continue;
			if(dp[i]) continue;
			
			//i .. i+2*j-1
			vector<bool> ta(2*n);
			bool bo=true;
			int up=i+2*j-1;
			int down=i;
			for(int k=0;k<n;k++){
				if(a[k]<0 && b[k]<0) continue;
				if(b[k]>=0 && b[k]<down) continue;
				if(a[k]>=0 && a[k]>up) continue;
				if(b[k]>=0 && a[k]<0 && b[k]>up) continue;
				if(a[k]>=0 && b[k]<0 && a[k]<down) continue;
				if(a[k]>=0 && b[k]>=0 && a[k]<down && b[k]>up){
					bo=false;
					break;
				}
				
				if(a[k]>=0 && b[k]>=0){
					if((b[k]-a[k])!=j || ta[b[k]] || ta[a[k]] || a[k]<down || b[k]>up){
						bo=false;
						break;
					}
					ta[a[k]]=true;
					ta[b[k]]=true;
				}else if(a[k]>=0){
					int bb=a[k]+j;
					if(bb>up || ta[a[k]] || ta[bb] || a[k]<down){
						bo=false;
						break;
					}
					ta[a[k]]=true;
					ta[bb]=true;
				}else{
					int aa=b[k]-j;
					if(aa<down || ta[aa] || ta[b[k]] || b[k]>up){
						bo=false;
						break;
					}
					ta[aa]=true;
					ta[b[k]]=true;
				}
			}
			for(int k=down;k<=up;k++){
				if(ta[k]) continue;
				if((k+j)>up) bo=false;
				if(ta[k+j]) bo=false;
				ta[k]=true;
				ta[k+j]=true;
			}
			if(!bo) continue;
			
			dp[i]=true;
			//cout << i << " " << j << "\n";
		}
		//cout << dp[i] << "\n";
	}
	if(dp[0]) cout << "Yes" << "\n";
	else cout << "No" << "\n";
	return 0;
}