#include using namespace std; using lint = long long; template using V = vector; template using VV = V< V >; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; V<> x{2, 3, 7}, y{8, 9, 9}; while (n--) { int a, b, c, d; cin >> a >> b >> c >> d; for (int i = 0; i < 3; ++i) if (x[i] == a and y[i] == b) { x[i] = c, y[i] = d; } } cout << (x == V<>{5, 4, 6} and y == V<>{8, 8, 8} ? "YES" : "NO") << '\n'; }