#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define st first
#define nd second
#define pii pair<int,int>
#define mp make_pair
#define pll pair<long long,long long>

using namespace std;

const int nax = 205;
vector<pii> parki;
int dp[nax];
int n;

void solve(){
    cin >> n;
    for(int i=1;i<=n;i++){
        int x, y; cin>>x>>y;
        parki.pb(mp(x, y));
    }

    dp[0] = 0;
    for(int i=1;i<=2*n;i++){
        dp[i] = 1e9;
        if(i & 1) continue;

        for(int lo=1;lo<i;lo+=2){
            int hi = i;
            bool ok = true;
            set<int> xd;
            int len = (hi - lo + 1);
            for(pii cur : parki){
                if(cur.st != - 1){
                    if(cur.st >= lo && cur.st < lo + len / 2){
                        if(xd.count(cur.st)) ok = false;
                        xd.insert(cur.st);
                        if(cur.nd != -1){
                            if(cur.nd != cur.st + len / 2) ok = false;
                        }
                    }
                }
                else if(cur.nd != -1){
                    // cur.st = -1
                    if(cur.nd >= lo + len / 2 && cur.nd <= hi){
                        if(xd.count(cur.nd - len / 2)) ok = false;
                        xd.insert(cur.nd - len / 2);
                    }
                }
            }

            if(ok){
                dp[i] = min(dp[i], dp[lo - 1] + (int)(len / 2 - xd.size()));
            }
        }
    }

    int cnt = 0;
    for(pii cur : parki){
        if(cur == mp(-1, -1)) cnt++;
    }
    if(dp[n * 2] == cnt) cout << "Yes" << "\n";
    else cout << "No" << "\n";

}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int tt = 1;
    // cin >> tt;
    while(tt--) solve();
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())
 
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
 
template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}
 
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}
 
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}
 
#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
 
int main() {
    int N;
    cin >> N;
    V<int> A(N), B(N);
    int sz = N * 2;
    V<int> tp(sz), com(sz, -1);
 
    bool ng = false;
 
    rep(i, N) {
        cin >> A[i] >> B[i];
        if (A[i] != -1) {
            --A[i];
            if (tp[A[i]]) ng = true;
            tp[A[i]] = i + 1;
        }
        if (B[i] != -1) {
            --B[i];
            if (tp[B[i]]) ng = true;
            tp[B[i]] = -(i + 1);
        }
 
        if (A[i] != -1 && B[i] != -1) {
            com[A[i]] = i;
            com[B[i]] = i;
        }
    }
    if (ng) {
        puts("No");
        return 0;
    }
 
    V<bool> dp(sz + 1);
    dp[0] = true;
 
    rep(i, sz) {
        if (!dp[i]) continue;
        for (int j = i + 1; j < sz; ++j) {
            int w = j - i + 1;
            if (w & 1) continue;
            w /= 2;
            bool ok = true;
 
            rep(k, w) {
                int p = i + k, q = i + k + w;
                if(com[p] != com[q])ok = false;
                if (tp[p] != 0 && tp[q] != 0) {
                    if (tp[p] < 0 || tp[p] + tp[q] != 0) {
                        ok = false;
                    } 
                }
                if (tp[p] < 0 || tp[q] > 0) {
                    ok = false;
                } 
            }
            if (ok) {
                dp[j + 1] = true;
            }
        }
    }
    puts(dp[sz] ? "Yes" : "No");
 
    return 0;
}
