We have N irregular jigsaw pieces. Each piece is composed of three rectangular parts of width 1 and various heights joined together. More specifically:

* The i-th piece is a part of height H, with another part of height A_i joined to the left, and yet another part of height B_i joined to the right, as shown below. Here, the bottom sides of the left and right parts are respectively at C_i and D_i units length above the bottom side of the center part.



<image>

Snuke is arranging these pieces on a square table of side 10^{100}. Here, the following conditions must be held:

* All pieces must be put on the table.
* The entire bottom side of the center part of each piece must touch the front side of the table.
* The entire bottom side of the non-center parts of each piece must either touch the front side of the table, or touch the top side of a part of some other piece.
* The pieces must not be rotated or flipped.



Determine whether such an arrangement is possible.

Constraints

* 1 \leq N \leq 100000
* 1 \leq H \leq 200
* 1 \leq A_i \leq H
* 1 \leq B_i \leq H
* 0 \leq C_i \leq H - A_i
* 0 \leq D_i \leq H - B_i
* All input values are integers.

Input

Input is given from Standard Input in the following format:


N H
A_1 B_1 C_1 D_1
A_2 B_2 C_2 D_2
:
A_N B_N C_N D_N


Output

If it is possible to arrange the pieces under the conditions, print `YES`; if it is impossible, print `NO`.

Examples

Input

3 4
1 1 0 0
2 2 0 1
3 3 1 0


Output

YES


Input

4 2
1 1 0 1
1 1 0 1
1 1 0 1
1 1 0 1


Output

NO


Input

10 4
1 1 0 3
2 3 2 0
1 2 3 0
2 1 0 0
3 2 0 2
1 1 3 0
3 2 0 0
1 3 2 0
1 1 1 3
2 3 0 0


Output

YES
#include <bits/stdc++.h>
#define f(a, n) for (int a=0; a<n; a++)
#define F(a, n) for (int a=1; a<=n; a++)
using namespace std;

struct node{
	vector<int> out;
	int in=0;
	int id;
	bool vis = 0;
};
node A[401];
int w, x, y, z;
int h, n;
bool fail = 0;
void visit(int x){
	if (A[x].vis) return;
	A[x].vis = 1;
	for (auto y: A[x].out) visit(y);
}
int main() {
	cin>>n>>h;
	f(i, 401) A[i].id = i;
	f(i, n){
		cin>>w>>x>>y>>z;
		int a, b;
		if (y==0) a=200+w; else a = y;
		if (z==0) b=x; else b=200+z; 
		A[a].out.push_back(b);
		A[b].in++;
	}
	f(i, 200){
		if (A[i].out.size()>A[i].in) fail = 1;
		f(j, A[i].in-int(A[i].out.size())) A[i].out.push_back(200);
	}
	F(i, 200){
		if (A[i+200].out.size()<A[i+200].in) fail = 1;
		f(j, int(A[i+200].out.size())-A[i+200].in) A[200].out.push_back(i+200);
	}
	
	visit(200);
	f(i, 401) if (A[i].out.size()>0 && !A[i].vis) fail = 1;
	cout<<(fail? "NO" : "YES")<<endl;
	
	/*Printing edges, debug
	f(i, 401){
		for (auto x:A[i].out){
			cout<<i<<" "<<A[x].id<<endl;
		}
	}*/
}