#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

bool solve() {
	int n = ri();
	int id[2 * n];
	for (auto &i : id) i = -1;
	int paired[2 * n];
	for (auto &i : paired) i = -1;
	for (int i = 0; i < n; i++) {
		int a = ri() - 1;
		int b = ri() - 1;
		if (a != -2 && b != -2 && a >= b) return false;
		if (a != -2) {
			if (id[a] != -1) return false;
			id[a] = i;
		}
		if (b != -2) {
			if (id[b] != -1) return false;
			id[b] = i;
		}
		if (a != -2 && b != -2) {
			paired[a] = b;
			paired[b] = a;
		}
	}
	bool ok[2 * n + 1];
	memset(ok, 0, sizeof(ok));
	ok[0] = 1;
	for (int i = 0; i < 2 * n; i++) {
		if (!ok[i]) continue;
		for (int j = 1; i + j * 2 <= 2 * n; j++) {
			bool t = true;
			for (int k = i; k < i + j; k++) if (id[k] != -1 && id[k + j] != -1 && id[k] != id[k + j]) { t = false; break; }
			for (int k = i; k < i + j; k++) if (id[k] != -1 && paired[k] != -1 && paired[k] != k + j) { t = false; break; }
			for (int k = i + j; k < i + j + j; k++) if (id[k] != -1 && paired[k] != -1 && paired[k] != k - j) { t = false; break; }
			if (t) ok[i + j * 2] = true;
		}
	}
	return ok[2 * n];
}

int main() {
	puts(solve() ? "Yes" : "No");
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define fr(i,n) for(int i = 0; i<n; i++)
#define sz(v) (int)(v.size())
#define prin(a) cout << #a << " = " << a << endl
#define prinv(v) cout << #v << " = "; for(auto it : v) cout << it << ", "; cout << endl
#define all(v) (v).begin(),(v).end()

typedef long long ll;

#define rmin(a,b) a = min<ll>(a,b)
#define rmax(a,b) a = max<ll>(a,b)

#define fi first
#define se second

const int N = 100;
int mat[N][N];
int n, m, a, b;
int ans = 0;

bool valid(int i, int j){
	return i>=0 and i<n and j>=0 and j<m;
}

bool poe(int cor, int io, int jo, int nn, int mm){
	fr(di,nn) fr(dj,mm){
		int i = io+di, j = jo+dj;
		if(!valid(i,j) or mat[i][j]==cor) return 0;
	}
	fr(di,nn) fr(dj,mm){
		int i = io+di, j = jo+dj;
		mat[i][j] = cor;
	}
	return 1;
}

void prinmat(){
	fr(i,n){
		fr(j,m) cout << mat[i][j];
		cout << endl;
	}
	cout << endl;
}

void rec(int id = 0){
	int achou = 0;
	//prin(id);
	fr(i,n) fr(j,m){
		if(!mat[i][j]){
			if(a and poe(1,i,j,2,1)){
				//prinmat();
				a--;
				rec(id+1);
				poe(0,i,j,2,1);
				a++;
				//prinmat();
			}
			if(a and poe(1,i,j,1,2)){
				a--;
				rec(id+1);
				poe(0,i,j,1,2);
				a++;
			}
			if(b and poe(1,i,j,1,1)){
				b--;
				rec(id+1);
				poe(0,i,j,1,1);
				b++;
			}
			achou = 1;
			goto sai;
		}
	}
	sai:
	if(!achou){ 
		ans++;
		//prin(id);
	}
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m >> a >> b;
	rec();
	cout << ans << "\n";
}