using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using System.Runtime.CompilerServices; //using System.Web.UI; using Debug = System.Diagnostics.Debug; // using System.Drawing.Primitives; using System.Drawing; using System.Windows; namespace ConsoleApp1 { class Program { static void Main(string[] args) { new Solver().Solve(); } } class Solver { public const double inf = double.PositiveInfinity; readonly TextWriter error = Console.Error; private void Rep(int n_, Action action) { for (int i = 0; i < n_; i++) { action(i); } } public string ReadLine() { return Console.ReadLine(); } public int Stoi(string s) { return int.Parse(s); } int n; public void Solve() { n = int.Parse(ReadLine()); var x = new int[n, 3]; var y = new int[n, 3]; Rep(n, (i) => { var a = ReadLine().Split(' ').Select(s => Stoi(s)).ToArray(); //Rep(2, (j) => //{ // x[i, 1 + j] = a[2 * j]; // y[i, 1 + j + 1] = a[2 * j]; //}); x[i, 1] = a[0]; y[i, 1] = a[1]; x[i, 2] = a[2]; y[i, 2] = a[3]; }); var cur = new int[10, 10]; cur[2, 8] = 1; cur[3, 9] = 2; cur[7, 9] = 3; Rep(n, (i) => { cur[x[i, 2], y[i, 2]] = cur[x[i, 1], y[i, 1]]; cur[x[i, 1], y[i, 1]] = 0; }); bool ok = false; if (cur[5, 8] == 1 && cur[4, 8] == 2 && cur[6, 8] == 3) ok = true; Console.WriteLine(ok ? "YES" : "NO"); } } }