#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

//#define debug(x) ;
#define debug(x) cerr << #x << " = " << x << "\n";

ostream& operator<<(ostream& cerr, vector<ll> aux) {
  cerr << "[";
  for (auto e : aux) cerr << e << ' ';
  cerr << "]";
  return cerr;
}

const int maxN = 211;

int n;
int a[maxN], b[maxN];
bool used[maxN], sol[maxN];

void result(bool yes) {
  cout << (yes ? "Yes" : "No");
  exit(0);
}

bool canTile(int l, int r) {
  int full = r - l;
  int half = full / 2;

  for (int i = l; i < r; i++) used[i] = false;
  for (int i = 0; i < n; i++) {
    int posX = a[i];
    int posY = b[i];

    bool outX = (posX < l || posX >= r);
    bool outY = (posY < l || posY >= r);

    if (outX && outY) continue;
    if (outX ^ outY) {
      // one in one out
      if (posX != -1 && posY != -1) return false;

      if (posX != -1) {
        if (posX >= l + half) return false;
        if (used[posX] || used[posX + half]) return false;
        used[posX] = true;
        used[posX + half] = true;
      }

      if (posY != -1) {
        if (posY < l + half) return false;
        if (used[posY] || used[posY - half]) return false;
        used[posY] = true;
        used[posY - half] = true;
      }

    } else {
      // both in
      if (posX >= l + half || posY < l + half) return false;
      if (posY - posX != half) return false;
      if (used[posX] || used[posY]) return false;
      used[posX] = used[posY] = true;
    }
  }

  return true;
}

int main()
{
  //freopen("test.in", "r", stdin);

  cin >> n;
  for (int i = 0; i < n; i++) { 
    cin >> a[i] >> b[i];
    if (a[i] != -1 && b[i] != -1 && a[i] >= b[i])
      result(false);
  }

  sol[0] = true;
  for (int i = 0; i < 2 * n; i++) {
    if (!sol[i]) continue;

    for (int j = i + 2; j <= 2 * n; j += 2) {
      if (sol[j]) continue;
      sol[j] |= canTile(i + 1, j + 1);
    }
  }

  result(sol[2 * n]);

  return 0;
}

       
   //                                                  '-.-'
   //                                         ()      __.'.__
   //                                      .-:--:-.  |_______|
   //                               ()      \____/    \=====/
   //                               /\      {====}     )___(
   //                    (\=,      //\\      )__(     /_____\
   //    __    |'-'-'|  //  .\    (    )    /____\     |   |
   //   /  \   |_____| (( \_  \    )__(      |  |      |   |
   //   \__/    |===|   ))  `\_)  /____\     |  |      |   |
   //  /____\   |   |  (/     \    |  |      |  |      |   |
   //   |  |    |   |   | _.-'|    |  |      |  |      |   |
   //   |__|    )___(    )___(    /____\    /____\    /_____\
   //  (====)  (=====)  (=====)  (======)  (======)  (=======)
   //  }===={  }====={  }====={  }======{  }======{  }======={
   // (______)(_______)(_______)(________)(________)(_________)
   //
   // Credits :- Joan G. Stark
   //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
   //|                      AUTHOR - KASPAROVIAN                                     |
   //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define frr(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fr first
#define sc second
#define mk make_pair
#define endl '\n'
#define MOD 1000000007
#define in insert
#define sz(x) (ll)(x).size()
#define mem(a,b) memset(a,b,sizeof(a))
#define int long long
#define runtime() ((double)clock() / CLOCKS_PER_SEC) 
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
#define TRACE 
  
#ifdef TRACE 
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) 
template <typename Arg1> 
void __f(const char* name, Arg1&& arg1){ 
    cerr << name << " : " << arg1 << endl; 
} 
template <typename Arg1, typename... Args> 
void __f(const char* names, Arg1&& arg1, Args&&... args){ 
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...); 
} 
#else 
#define trace(...) 
#endif 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pi;
typedef pair<int,pi> ppi;
typedef vector<vi> graph;
template<class T> void mxi(T & a, const T & b) { a = max(a, b); }
template<class T> void mni(T & a, const T & b) { a = min(a, b); }
ld EPS=1e-9;
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count());  
#define SHUF(v) shuffle(all(v), RNG); 
// Use mt19937_64 for 64 bit random numbers. 
void solve()
{
  int n; cin>>n;
  n*=2;
  int ans=0;
  for(int i=1;i*i<=n;i++)
  {
  	if(n%i==0)
  	{
  		int val=(int)(n/i)-(i+1);
  		if(abs(val)%(2)==0)ans++;
  		if(i*i!=n)
  		{
  			int d=n/i;
  			val=(int)(n/d)-(d+1);
  			if(abs(val)%(2)==0)ans++;
  		}
  	}
  }
  cout<<ans<<endl;
}
signed main()
{
  fast;
  int t,tab;
  t=1;
  tab=t;
  while(t--)
  {
    //cout<<"Case #"<<(tab-t)<<": ";
    solve();
  }
  cerr<<runtime();
}
//APPROACHING A QUESTION
//+ Think of binary search (max of min etc also if n<=2*10^5)
//+ Think of common dp states (Even if it appears as maths but constraints are small)
//+ Check constraints
//+ Keep calm and enjoy the question
//+ Be sure to remove MOD from binpow (if needed)
//+ Try bidirectional analysis for constructive questions
//+ If given some sequence try thinking of prefix sums
//+ If constraints are too large maybe its simple maths
//+ In questions with binary operations think of bits independently and also the change pattern
//+ If two or more binary operations are given mostly there is a relation between them and an arithmatic operator