#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 998244353
#define pii pair<ll,ll>
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define autoitr(x,it) for(auto it = x.rbegin(); it != x.rend(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

ll powa(ll a, ll b, ll c)
{
    a%=c;
    if(a<0)
    a+=c;
    ll res = 1;
    while(b>0)
    {
        if(b&1)
            res*=a, res%=c;
        a*=a, a%=c;
        b>>=1;
    }
    return res;
}
 
ll norm(ll a)
{
    a%=mod;
    if(a<0)
        a+=mod;
    return a;    
}
 
ll add(ll a, ll b)
{
    a = norm(a);
    b = norm(b);
    return norm(a+b);
}
 
ll mul(ll a, ll b)
{
    a = norm(a);
    b = norm(b);
    return norm(a*b);
}
 
 
ll sub(ll a, ll b)
{
    a = norm(a);
    b = norm(b);
    return norm(a-b);
}
 
ll divi(ll a, ll b)
{
    b = powa(b,mod-2,mod);
    return mul(a,b);
}

#define N 200005
 
ll fact[N];
ll ifact[N];
 
ll ncr(ll n, ll r)
{
    if(r>n)
        return 0;
    ll ans = fact[n];
    ans*=ifact[r];
    ans%=mod;
    ans*=ifact[n-r];
    ans%=mod;
    return ans;
}

#define N1 19

int main()
{
  FAST/**/
   
   fact[0] = 1;
   for(ll i=1;i<N;i++)
        fact[i] = fact[i-1]*i, fact[i]%=mod;
   for(ll i=0;i<N;i++)
        ifact[i] = powa(fact[i],mod-2,mod);     
   
   ll n,m;
   cin>>n>>m;
  
   vector<ll> div[m+1];
   for(ll i=1;i<=m;i++)
   {
       for(ll j=i;j<=m;j+=i)
            div[j].pb(i);
   }
   ll dp[N1][m+1];
   memset(dp,0,sizeof(dp));
   
   for(ll i=1;i<=m;i++)
   {
       dp[1][i] = 1;
       for(ll j=2;j<N1;j++)
       {
           autoit(div[i], it)
           {
               if(*it < i)
                    dp[j][i]+=dp[j-1][*it], dp[j][i]%=mod;
           }
       }
   }
   
   ll ans = 0;
   for(ll i=1;i<=m;i++)
   {
       for(ll j=1;j<N1;j++)
       {
           ans = add(ans, mul(ncr(n-1, j-1), dp[j][i]));
           //cout<<"for "<<i<<" , "<<j<<" = "<<dp[j][i]<<"\n";
       }
   }
   cout<<ans<<"\n";
   
   return 0;        
}  

   
 
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define mod 1000000007
#define ad(a,b) a=(a+b)%mod;
#define X 200010
ll po(ll x,ll y){
	ll res=1;
	for(;y;y>>=1){
		if(y&1)res=res*x%mod;
		x=x*x%mod;
	}
	return res;
}
ll gcd(ll a,ll b){
	return (b?gcd(b,a%b):a);
}
ll fac[X],ivf[X];
void initfac(){
	fac[0]=1;
	for(ll i=1;i<X;i++)fac[i]=fac[i-1]*i%mod;
	for(ll i=0;i<X;i++)ivf[i]=po(fac[i],mod-2);
}
ll C(ll n,ll k){
	return fac[n]*ivf[n-k]%mod*ivf[k]%mod;
}

ll n,a[210],b[210];
vector<ll> A[210],B[210];//A[p]:=(a[i]==p)=なるiのset
bool f[210][210];
bool solve(){
	cin>>n;
	rep(i,n){
		cin>>a[i]>>b[i];
		if(a[i]>=0)a[i]--;
		if(b[i]>=0)b[i]--;
		if(a[i]!=-1&&b[i]!=-1&&a[i]>=b[i])return 0;
		if(a[i]>=0)A[a[i]].push_back(i);
		if(b[i]>=0)B[b[i]].push_back(i);
	}
	rep(i,2*n){
		if(A[i].size()+B[i].size()>1)return 0;
	}//重複なし
	for(int i=0;i<=2*n;i++)for(int j=0;j<=2*n;j++)f[i][j]=0;
	for(int l=0;l<2*n;l+=2){
		for(int k=1;l+2*k<=2*n;k++){
			int r=l+2*k;
			bool ok=1;
			rep(i,n){
				bool va=(l<=a[i]&&a[i]<r);
				bool vb=(l<=b[i]&&b[i]<r);
				if(a[i]>=0&&b[i]>=0){
					if(va==0&&vb==0)continue;
					if(va==1&&vb==1){
						ok&=(a[i]+k==b[i]);
						continue;
					}
					ok=0;
				}
				else if(a[i]==-1&&b[i]==-1)continue;
				else if(a[i]>=0){
					if(va==0)continue;
					if(not(0<=a[i]+k&&a[i]+k<2*n))ok=0;
					else if(A[a[i]+k].size()+B[a[i]+k].size()>0)ok=0;
				}
				else if(b[i]>=0){
					if(vb==0)continue;
					if(not(0<=b[i]-k&&b[i]-k<2*n))ok=0;
					else if(A[b[i]-k].size()+B[b[i]-k].size()>0)ok=0;
				}
			}
			f[l][r]=ok;
			//cerr<<"f["<<l<<"]["<<r<<"]="<<f[l][r]<<endl;
		}
	}
	bool dp[210];
	for(int i=0;i<=2*n;i++)dp[i]=0;
	dp[0]=1;
	for(int i=0;i<2*n;i++){
		if(dp[i]==0)continue;
		for(int j=i+1;j<=2*n;j++){
			if(f[i][j]==1){
				dp[j]=1;
			}
		}
	}
	return dp[2*n];
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<(solve()?"Yes":"No")<<endl;
	
}
