#include <bits/stdc++.h>
using namespace std;
#define clear(a) memset(a, 0, sizeof(a))
#define full(a) memset(a, 0x3f, sizeof(a))
#define fornext(x, i) for(int i = head[x], y = ver[i]; i; i = nxt[i], y = ver[i])
#define mset(a, b) memset(a, b, sizeof(a))
#define Rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define dRep(i, a, b) for(int i = (a); i >= (b); --i)
#define IOset(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout);
#define int ll
#define un unsigned
#define ll long long
#define db double
#define dbg cout<<"c "

template<typename _T>
inline void rd(_T &dig) {
	int flg; char c;
	flg = dig = 0;
	while (c = getchar(), !isdigit(c)) if (c == '-') flg = 1;
	while (isdigit(c)) dig = dig * 10 + c - '0', c = getchar();
	if (flg) dig = -dig;
}

template <typename _T, typename ...Args>
inline void rd(_T &dig, Args &...args) {
	rd(dig);
	rd(args...);
}

const int N = 505;
int f[N][N], g[N], a[N], b[N], ty[N], n, ex[N], id[N];	//-1~1 / 0

void no() {
	puts("No");
	exit(0);
}

signed main() {
	rd(n);
	Rep(i, 1, n) {
		rd(a[i], b[i]);
		if (a[i] != -1 && b[i] != -1 && a[i] >= b[i]) no();
		if (a[i] != -1) {
			if (ex[a[i]]) no();
			ex[a[i]] = 1;
			ty[a[i]] = -1;
			id[a[i]] = i;
		}
		if (b[i] != -1) {
			if (ex[b[i]]) no();
			ex[b[i]] = 1;
			ty[b[i]] = 1;
			id[b[i]] = i;
		}
	}
	n *= 2;
	/*
	Rep(i, 2, (n + 2) / 2) {
		Rep(j, 1, n + 3 - 2 * i) {
			Rep(k, j, j + i - 2) {
				if (id[k]) {
					if (ty[k] == 1 || (b[id[k]] != -1 && b[id[k]] != k + i - 1)) {
						f[j][i] = -1;
						break;
					}
				}
				if (id[k + i - 1]) {
					if (ty[k + i - 1] == -1 || (a[id[k + i - 1]] != -1 && a[id[k + i - 1]] != k)) {
						f[j][i] = -1;
						break;
					}
				}
			}
		}
	}*/
	int l, r;
	Rep(i, 1, n) Rep(j, 1, i) f[i][j] = -1;
	Rep(i, 1, n) Rep(j, i + 1, n) {
		if (j - i + 1 % 2 == 1) {
			f[i][j] = -1;
			continue;
		}
		l = (j-i + 3) / 2;
		Rep(k, i, i + l - 2) {/*
			if (id[k]) {
				if (ty[k] == -1 && ((b[id[k]] == -1 && !id[k + l - 1]) || b[id[l]] == k + l - 1));
				else f[i][j] = -1;
			}
			if (id[r]) {
				if (ty[r] == 1 && ((a[id[r]] == -1 && !id[k]) || a[id[r]] == k));
				else f[i][j] = -1;
			}*/
			r = k + l - 1;
			if(id[k] && id[r] && id[k]!=id[r]) f[i][j]=-1;
			if(id[k] && !id[r]&&(ty[k]!=-1||b[id[k]]!=-1)) f[i][j]=-1;
			if(id[r] && !id[k]&&(ty[r]!=1||a[id[r]]!=-1)) f[i][j]=-1;
		}
	}
	g[0] = 1;
	Rep(i, 1, n) {
		Rep(j, 0, i - 2) if (g[j] && (f[j + 1][i] != -1)) g[i] = 1;
	}
	if (g[n]) puts("Yes");
	else puts("No");
	return 0;
}

#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int n;

int p[201];

vector<pair<int,int> > v;
map<pair<int, int>, int > mp;

bool solve(int le, int ri){
    if(mp[{le, ri}] == 1) return true;
    else if(mp[{le, ri}] == -1) return false;
    bool ret = false;
    for(int i=le + 1; i <= ri - 2;i += 2){
        if(solve(le, i) && solve(i+1, ri)) ret = true;
    }
    if(ret){
        mp[{le, ri}] = 1;
        return true;
    }


    int m = ri - le + 1;
    m /= 2;

    ret = true;
    for(int i = le ; i < le + m ;i++){
        if(p[i] == -1){
            if(p[i+m] == -1){
                continue;
            }
            else{
                if(v[p[i+m]].first != -1 && v[p[i+m]].first != i) ret = false;
                if(v[p[i+m]].second != -1 && v[p[i+m]].second != i+m) ret = false;
            }
        }else{
            if(p[i+m] == -1){
                if(v[p[i]].first != -1 && v[p[i]].first != i) ret = false;
                if(v[p[i]].second != -1 && v[p[i]].second != i+m) ret = false;
            }
            else{
                if(p[i] != p[i+m]) ret = false;
                if(v[p[i]].first != -1 && v[p[i]].first != i) ret = false;
                if(v[p[i]].second != -1 && v[p[i]].second != i+m) ret = false;
            }
        }
    }
    if(ret){
        mp[{le, ri}] = 1;
        return true;
    }else{
        mp[{le, ri}] = -1;
        return false;
    }
}

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    int a, b;
    
    bool ok = true;
    memset(p, -1, sizeof(p));
    for(int i=0;i<n;i++){
        cin >> a >> b;
        if(a != -1){
            if(p[a] != -1){
                ok = false;
            }
            p[a] = i;
        }
        if(b != -1){
            if(p[b] != -1 || b < a){
                ok = false;
            }
            p[b] = i;
        }

        v.push_back({a, b});
    }
    if(!ok){
        cout << "No" << endl;
        return 0;
    }
    if(solve(1, n*2)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}
