#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <chrono>

#define int long long
#define ld long double
#define db double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define debx cout << " X " << endl;
#define deby cout << " Y " << endl;
#define debz cout << " Z " << endl;

using namespace __gnu_pbds; 
using namespace std;
using namespace chrono;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update> ; 
/*  
    find_by_order() - Returns an iterator to the k-th largest element (counting from zero) 
    order_of_key()  - The number of items in a set that are strictly smaller than our item 
    Rest same as set
*/

void deb_out() { 
    cout << endl; 
}
template <typename Head, typename... Tail>
void deb_out(Head H, Tail... T) {
    cout << " " << H;
    deb_out(T...);
}
#ifdef LOCAL
    #define deb(...) cout << "[" << #__VA_ARGS__ << "]:", deb_out(__VA_ARGS__);
#else
    #define deb(...)
#endif

const long double PI = 3.14159265358979323846264338;
const long long INF = 1000000000000000000;
const long long INF1 = 1000000000;
const long long MOD = 1000000007;
// const long long MOD = 998244353;

int mpow(int a, int b){
    a %= MOD;
    if(!b)
        return 1;
    int temp = mpow(a, b / 2);
    temp = (temp * temp) % MOD;
    if(b % 2)
        return (a * temp) % MOD;
    return temp;
}
int _pow(int a, int b){
    if(!b)
        return 1;
    int temp = _pow(a, b / 2);
    temp = (temp * temp);
    if(b % 2)
        return (a * temp);
    return temp;
}
inline int mod_in(int n){
    return mpow(n, MOD - 2);
}
inline int cl(int a, int b){
    if(a % b)
        return 1 + a / b;
    return a / b;
}
inline int rnd(int l = -INF, int r = INF){
    int v = rng();
    v = abs(v);
    return l + v % (r - l + 1);
}
int32_t main(){
    fastio;
    int Tests = 1;
    // cin >> Tests;
    while (Tests--) {
        int a, b;
        cin >> a >> b;
        cout << 2 * a + 100 - b << endl;
    }
}
#include <bits/stdc++.h>
using namespace std;

const int N = 200 + 1;

bool possible[N];
int id[N];
int a[N];
int b[N];

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

  int n;
  cin >> n;

  fill(id, id + 2 * n, -1);
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
    if (a[i] != -1) {
      if (id[--a[i]] != -1) {
        cout << "No\n";
        exit(0);
      }
      id[a[i]] = i;
    }
    if (b[i] != -1) {
      if (id[--b[i]] != -1) {
        cout << "No\n";
        exit(0);
      }
      id[b[i]] = i;
    }
  }

  possible[2 * n] = true;
  for (int i = 2 * n - 2; i >= 0; i -= 2) {
    for (int j = 1; i + 2 * j <= 2 * n && !possible[i]; ++j) {
      if (!possible[i + 2 * j]) {
        continue;
      }

      bool ok = true;
      for (int k = 0; k < j && ok; ++k) {
        int l = i + k;
        int r = i + k + j;

        if (id[l] != -1 && a[id[l]] != l) {
          ok = false;
        }

        if (id[r] != -1 && b[id[r]] != r) {
          ok = false;
        }

        if (id[l] != id[r]) {
          if (id[l] != -1 && id[r] != -1) {
            ok = false;
          } else if (id[l] == -1) {
            ok &= (a[id[r]] == -1);
          } else {
            ok &= (b[id[l]] == -1);
          }
        }
      }

      possible[i] |= ok;
    }
  }

  cout << (possible[0] ? "Yes" : "No") << "\n";
}
