using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace bla
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            long n = int.Parse(s[0]);
            k = int.Parse(s[1]);

            arr = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        }

        static Dictionary<Tuple<long, long>, long> dp = new Dictionary<Tuple<long, long>, long>();

        static long r(int l, int r, long s, long p)
        {
            Tuple<long, long> lr = new Tuple<long, long>(l, r);
            if (dp.ContainsKey(lr))
                return dp[lr];

            long e = 0;
            if (s * k == p)
                e++;

            dp[lr] = e;
            return e;
        }

        static int[] arr;
        static long k;
    }
}


using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace Task
{
  class Program
  {
    static bool InRange(int l, int r, int x)
    {
      return x >= l && x <= r;
    }

    static void Main(string[] args)
    {
      var inpMas = Console.ReadLine().Split(' ').Select(item => int.Parse(item)).ToList();
      int l = inpMas[0];
      int r = inpMas[1];
      int x = inpMas[2];
      int y = inpMas[3];

      int i = 0;
      int ans = 0;
      int yx = y / x;
      int yx2 = yx;
      List<int> divs = new List<int>();
      int div = 2;

      int k = 0;
      while (yx2 % div == 0)
      {
        k += 1;
        yx2 >>= 1;
      }
      if (k > 0)
          divs.Add((int)Math.Pow(div, k));

      div = 3;
      while (yx2 > 1)
      {
        k = 0;
        while (yx2 % div == 0)
        {
          k += 1;
          yx2 /= div;
        }
        if (k > 0)
          divs.Add((int)Math.Pow(div, k));
        div += 2;
      }

      div = 1 << divs.Count;
      for (i = 1; i <= div; i ++)
      {
        int j = i;
        int div1 = 1;
        int ind = divs.Count - 1;
          while (j > 0)
        {
          if ((j & 1) == 1)
          {
            div1 *= divs[ind];
            ind -= 1;
          }
          j >>= 1;
        }
        int div2 = yx / div1;
          if (InRange(l, r, div1) && InRange(l, r, div2))
        ans += 1;
      }

      Console.WriteLine(ans);
    }
  }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProgrammingContest.Codeforces.Round14
{
    class C
    {
        public static void Main()
        {
            long[] x1 = new long[4];
            long[] x2 = new long[4];
            long[] y1 = new long[4];
            long[] y2 = new long[4];
            for (int i = 0; i < 4; i++)
            {
                string[] s = Console.ReadLine().Split(' ');
                x1[i] = long.Parse(s[0]);
                y1[i] = long.Parse(s[1]);
                x2[i] = long.Parse(s[2]);
                y2[i] = long.Parse(s[3]);
            }
            int[] xPar = new int[4];
            int[] yPar = new int[4];
            int x = 0, y = 0;
            for (int i = 0; i < 4; i++)
            {
                if (x1[i] == x2[i])
                {
                    yPar[y++] = i;

                    if(y1[i] > y2[i])
                    {
                        long temp = y1[i];
                        y1[i] = y2[i];
                        y2[i] = temp;
                    }
                }
                else if (y1[i] == y2[i])
                {
                    xPar[x++] = i;

                    if(x1[i] > x2[i])
                    {
                        long temp = x1[i];
                        x1[i] = x2[i];
                        x2[i] = temp;
                    }
                }
                else
                {
                    Console.WriteLine("NO");
                    return;
                }
            }
            if (x != 2 || y != 2)
            {
                Console.WriteLine("NO");
                return;
            }

            if (x1[yPar[0]] > x1[yPar[1]])
            {
                int temp = yPar[0];
                yPar[0] = yPar[1];
                yPar[1] = temp;
            }

            if (y1[xPar[0]] > y1[xPar[1]])
            {
                int temp = xPar[0];
                xPar[0] = xPar[1];
                xPar[1] = temp;
            }
#if false
            Console.WriteLine("xPar[0]:({0},{2}) ({1},{3})", x1[xPar[0]], x2[xPar[0]], y1[xPar[0]], y2[xPar[0]]);
            Console.WriteLine("xPar[1]:({0},{2}) ({1},{3})", x1[xPar[1]], x2[xPar[1]], y1[xPar[1]], y2[xPar[1]]);
            Console.WriteLine("yPar[0]:({0},{2}) ({1},{3})", x1[yPar[0]], x2[yPar[0]], y1[yPar[0]], y2[yPar[0]]);
            Console.WriteLine("yPar[1]:({0},{2}) ({1},{3})", x1[yPar[1]], x2[yPar[1]], y1[yPar[1]], y2[yPar[1]]);
#endif
            if (x1[yPar[0]] == x1[xPar[0]] && x1[yPar[0]] == x1[xPar[1]] &&
                x1[yPar[1]] == x2[xPar[0]] && x1[yPar[1]] == x2[xPar[1]] &&
                y1[xPar[0]] == y1[yPar[0]] && y1[xPar[0]] == y1[yPar[1]] &&
                y1[xPar[1]] == y2[yPar[0]] && y1[xPar[1]] == y2[yPar[1]])
            {
                Console.WriteLine("YES");
            }
            else Console.WriteLine("NO");
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace code_29
{
    class Program
    {
        static void Main(string[] args)
        {
            bool b=false;
            int[][] mas = new int[4][];
            for (int i = 0; i < 4; i++)
            {
                string s = Console.ReadLine();
                mas[i] = (from v in s.Split(' ') let q = int.Parse(v) select q).ToArray();
            }
            for (int i = 0; i < 4; i++)//point
            {
                if (mas[i][0] == mas[i][2] && mas[i][1] == mas[i][3])
                    b = true;

            }
            if (b) { Console.WriteLine("NO"); return; }
            for (int i = 0; i < 4; i++)//parall
            {
                if (mas[i][0] != mas[i][2] && mas[i][1] != mas[i][3])
                    b = true;
            }
            if (b) { Console.WriteLine("NO"); return; }
            int[,] connect = new int[4, 4];
            for (int i = 0; i < 4; i++)
                for (int j = 0; j < 4; j++)
                {
                    connect[i, j] = -1;
                }

            for (int i = 0; i < 3; i++)//connect
            {
                bool zapis1 = false;
                bool zapis2 = false;

                for (int j = 0; j < 4; j++)
                {
                    if (i == j) continue;
                    if (mas[i][0] == mas[j][0] && mas[i][1] == mas[j][1])
                    {
                        if (connect[j, 2] == i) b = true;

                        if (connect[j, 0] == -1)
                        {
                            connect[j, 0] = i;
                            connect[j, 1] = i;
                            zapis1 = true;
                        }
                        else
                            b = true;
                    }
                    else
                        if (mas[i][0] == mas[j][2] && mas[i][1] == mas[j][3])
                        {
                            if (connect[j, 0] == i) b = true;

                            if (connect[j, 2] == -1)
                            {
                                connect[j, 2] = i;
                                connect[j, 3] = i;
                                zapis1 = true;
                            }
                            else
                                b = true;
                        }

                    if (mas[i][2] == mas[j][0] && mas[i][3] == mas[j][1])
                    {
                        if (connect[j, 2] == i) b = true;
                        if (connect[j, 0] == -1)
                        {
                            connect[j, 0] = i;
                            connect[j, 1] = i;
                            zapis2 = true;
                        }
                        else
                            b = true;
                    }
                    else
                        if (mas[i][2] == mas[j][2] && mas[i][3] == mas[j][3])
                        {
                            if (connect[j, 0] == i) b = true;

                            if (connect[j, 2] == -1)
                            {
                                connect[j, 2] = i;
                                connect[j, 3] = i;
                                zapis2 = true;
                            }
                            else
                                b = true;
                        }

                }
                if (zapis1 && zapis2) { }
                else b = true;
            }
            if (b)  Console.WriteLine("NO");
            else Console.WriteLine("YES");

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Codeforce
{

    class Printer
    {
        StringBuilder sb;

        public Printer()
        {
            sb = new StringBuilder();
        }

        public void WriteLine(string s)
        {
            sb.AppendLine(s);
        }
        public void WriteLine()
        {
            sb.AppendLine();
        }
        public void Write(string s)
        {
            sb.Append(s);
        }

        public void Print()
        {
            Console.Write(sb);
        }
    }

    class Program
    {
        static StreamReader input = new StreamReader(Console.OpenStandardInput());
        //static StreamWriter output = new StreamWriter(Console.OpenStandardOutput());

        static int nextInt()
        {
            int t = input.Read();
            while ((t < '0' || t > '9') && t != '-') t = input.Read();
            int sign = 1;
            if (t == '-')
            {
                sign = -1;
                t = input.Read();
            }
            int x = 0;
            while (t >= '0' && t <= '9')
            {
                x *= 10;
                x += t - '0';
                t = input.Read();
            }
            return x * sign;
        }

        static int[] parseInt(string s)
        {
            string[] temp = s.Split(' ');
            int[] res = new int[temp.Length];
            for (int i = 0; i < temp.Length; i++)
            {
                res[i] = Convert.ToInt32(temp[i]);
            }
            return res;
        }

        static double Dist(double x1, double y1, double x2, double y2)
        {
            return Math.Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
        }
        struct Point
        {
            public double x { get; set; }
            public double y { get; set; }

            public Point(double _x, double _y)
                : this()
            {
                x = _x;
                y = _y;
            }
            public double DistTo(Point p2)
            {
                return Dist(x, y, p2.x, p2.y);
            }
        }

        class Segment
        {
            public Point first { get; set; }
            public Point last { get; set; }

            public Segment()
            {

            }
            public Segment(Point f, Point l)
            {
                first = f;
                last = l;
            }

            public void Swap()
            {
                Point tmp = first;
                first = last;
                last = tmp;
            }
        }
        static bool[] used = new bool[4];

        static bool isP(int i, Segment[] P, int length)
        {
            if (!(P[i].first.x == P[i].last.x || P[i].first.y == P[i].last.y) || length > 5)
                return false;
            if (length == 5 && i == 0)
                return true;

            int j = i + 1 < 4 ? i + 1 : 0;
            if ((!used[j] || j == 0) && P[i].last.x == P[j].first.x && P[i].last.y == P[j].first.y && (P[j].first.x == P[j].last.x || P[j].first.y == P[j].last.y))
            {
                used[j] = true;
                return isP(j, P, length + 1);
            }

            return false;
        }

        static void Main(string[] args)
        {
            Printer printer = new Printer();

            List<Segment> P = new List<Segment>();

            Segment[] S = new Segment[4];

            int xmin = int.MaxValue, xmax = int.MinValue, ymin = int.MaxValue, ymax = int.MinValue;
            Dictionary<string, int> D = new Dictionary<string, int>();
            for (int i = 0; i < 4; i++)
            {
                var tmp = parseInt(Console.ReadLine());

                xmin = Math.Min(xmin, tmp[0]);
                xmin = Math.Min(xmin, tmp[2]);
                xmax = Math.Max(xmax, tmp[0]);
                xmax = Math.Max(xmax, tmp[2]);

                ymin = Math.Min(ymin, tmp[1]);
                ymin = Math.Min(ymin, tmp[3]);
                ymax = Math.Max(ymax, tmp[1]);
                ymax = Math.Max(ymax, tmp[3]);

                string f = tmp[0].ToString() + " " + tmp[1].ToString() ;
                if (D.Keys.Contains(f))
                {
                    D[f]++;
                }
                else
                    D[f] = 1;
                f = tmp[2].ToString() + " " + tmp[3].ToString();
                if (D.Keys.Contains(f))
                {
                    D[f]++;
                }
                else
                    D[f] = 1;
                P.Add(new Segment(new Point(tmp[0], tmp[1]), new Point(tmp[2], tmp[3])));
            }

            if (xmin == xmax || ymin == ymax || D.Count != 4)
            {
                Console.WriteLine("NO");
                return;
            }

            for (int i = 0; i < 4; i++)
            {
                if (P[i].first.x == xmin && P[i].first.y == ymax && P[i].last.x == xmax && P[i].last.y == ymax
                 || P[i].last.x == xmin && P[i].last.y == ymax && P[i].first.x == xmax && P[i].first.y == ymax)
                {
                    used[1] = true;
                }
                if (P[i].first.x == xmin && P[i].first.y == ymin && P[i].last.x == xmin && P[i].last.y == ymax
                 || P[i].last.x == xmin && P[i].last.y == ymin && P[i].first.x == xmin && P[i].first.y == ymax)
                {
                    used[0] = true;
                }
                if (P[i].first.x == xmin && P[i].first.y == ymin && P[i].last.x == xmax && P[i].last.y == ymin
                 || P[i].last.x == xmin && P[i].last.y == ymin && P[i].first.x == xmax && P[i].first.y == ymin)
                {
                    used[2] = true;
                }
                if (P[i].first.x == xmax && P[i].first.y == ymin && P[i].last.x == xmin && P[i].last.y == ymin
                 || P[i].last.x == xmax && P[i].last.y == ymin && P[i].first.x == xmin && P[i].first.y == ymin)
                {
                    used[3] = true;
                }
            }

            for (int i = 0; i < 4; i++)
            {
                if (!used[i])
                {
                    Console.WriteLine("NO");
                    return;
                }
            }
            Console.WriteLine("YES");
            printer.Print();

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace code_29
{
    class Program
    {
        static void Main(string[] args)
        {
            bool b=false;
            int[][] mas = new int[4][];
            for (int i = 0; i < 4; i++)
            {
                string s = Console.ReadLine();
                mas[i] = (from v in s.Split(' ') let q = int.Parse(v) select q).ToArray();
            }
            for (int i = 0; i < 4; i++)//point
            {
                if (mas[i][0] == mas[i][2] && mas[i][1] == mas[i][3])
                    b = true;

            }
            if (b) { Console.WriteLine("NO"); return; }
            for (int i = 0; i < 4; i++)//parall
            {
                if (mas[i][0] != mas[i][2] && mas[i][1] != mas[i][3])
                    b = true;
            }
            if (b) { Console.WriteLine("NO"); return; }
            int[,] connect = new int[4, 4];
            for (int i = 0; i < 4; i++)
                for (int j = 0; j < 4; j++)
                {
                    connect[i, j] = -1;
                }

            for (int i = 0; i < 4; i++)//connect
            {
                bool zapis1 = false;
                bool zapis2 = false;

                for (int j = 0; j < 4; j++)
                {
                    if (i == j) continue;
                    if (mas[i][0] == mas[j][0] && mas[i][1] == mas[j][1])
                    {
                        if (connect[j, 2] == i) b = true;

                        if (connect[j, 0] == -1)
                        {
                            connect[j, 0] = i;
                            connect[j, 1] = i;
                            zapis1 = true;
                        }
                        else
                            b = true;
                    }
                    else
                        if (mas[i][0] == mas[j][2] && mas[i][1] == mas[j][3])
                        {
                            if (connect[j, 0] == i) b = true;

                            if (connect[j, 2] == -1)
                            {
                                connect[j, 2] = i;
                                connect[j, 3] = i;
                                zapis1 = true;
                            }
                            else
                                b = true;
                        }

                    if (mas[i][2] == mas[j][0] && mas[i][3] == mas[j][1])
                    {
                        if (connect[j, 2] == i) b = true;
                        if (connect[j, 0] == -1)
                        {
                            connect[j, 0] = i;
                            connect[j, 1] = i;
                            zapis2 = true;
                        }
                        else
                            b = true;
                    }
                    else
                        if (mas[i][2] == mas[j][2] && mas[i][3] == mas[j][3])
                        {
                            if (connect[j, 0] == i) b = true;

                            if (connect[j, 2] == -1)
                            {
                                connect[j, 2] = i;
                                connect[j, 3] = i;
                                zapis2 = true;
                            }
                            else
                                b = true;
                        }

                }
                if (zapis1 && zapis2) { }
                else b = true;
            }
            if (b)  Console.WriteLine("NO");
            else Console.WriteLine("YES");

        }
    }
}


using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.IO;

class Program
{
    class Point: IComparable<Point>
    {
        public int x, y;
        public Point(int x, int y)
        {
            this.x = x;
            this.y = y;
        }
        public int CompareTo(Point other)
        {
            if (other.x != x)
                return x - other.x;
            else
                return y - other.y;
        }
        public override bool Equals(object obj)
        {
            Point other = (Point)obj;
            return other.x == x && other.y == y;
        }
    }
    class Seg
    {
        public Point a, b;
        public Seg(Point a, Point b)
        {
            this.a = a;
            this.b = b;
        }
        public void revert()
        {
            Point temp = a;
            a = b;
            b = temp;
        }
    }
    void solve()
    {
        Seg[] seg = new Seg[4];
        for (int i = 0; i < 4; i++)
        {
            seg[i] = new Seg(new Point(nextInt(), nextInt()), new Point(nextInt(), nextInt()));
        }
        List<Seg> vertical = new List<Seg>();
        List<Seg> horizontal = new List<Seg>();
        foreach (Seg s in seg)
        {
            if (s.a.x == s.b.x)
            {
                vertical.Add(s);
            }
            else if (s.a.y == s.b.y)
            {
                horizontal.Add(s);
            }
            else
            {
                Console.WriteLine("NO");
                return;
            }
        }
        if (vertical.Count < 2 || horizontal.Count < 2)
        {
            Console.WriteLine("NO");
            return;
        }
        foreach (Seg s in vertical)
        {
            if (s.a.y > s.b.y)
                s.revert();
        }
        foreach (Seg s in horizontal)
        {
            if (s.a.x < s.b.y)
                s.revert();
        }
        int height1 = vertical[0].b.y - vertical[0].a.y;
        int height2 = vertical[1].b.y - vertical[1].a.y;
        int width1 = horizontal[0].b.x - horizontal[0].a.x;
        int width2 = horizontal[1].b.x - horizontal[1].a.x;
        if (height1 != height2 || width1 != width2 || height1==0 ||  width1==0)
        {
            Console.WriteLine("NO");
            return;
        }
        if (vertical[0].a.x > vertical[1].a.x)
        {
            Seg temp = vertical[0];
            vertical[0] = vertical[1];
            vertical[1] = temp;
        }
        if (horizontal[0].a.y > horizontal[1].a.y)
        {
            Seg temp = horizontal[0];
            horizontal[0] = horizontal[1];
            horizontal[1] = temp;
        }
        if (!vertical[0].a.Equals(horizontal[0].a))
        {
            Console.WriteLine("NO");
            return;
        }
        if (!vertical[0].b.Equals(horizontal[1].a))
        {
            Console.WriteLine("NO");
            return;
        }
        Console.WriteLine("YES");

    }

    //

    string[] inputLine = new string[0];
    int inputInd = 0;
    string nextLine()
    {
        return Console.ReadLine();
    }
    void readInput()
    {
        if (inputInd != inputLine.Length)
            throw new Exception();
        inputInd = 0;
        inputLine = Console.ReadLine().Split();

    }
    int nextInt()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return int.Parse(inputLine[inputInd++]);
    }
    long nextLong()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return long.Parse(inputLine[inputInd++]);
    }
    double nextDouble()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return double.Parse(inputLine[inputInd++]);
    }
    string nextString()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return inputLine[inputInd++];
    }
    static void Main(string[] args)
    {
        new Program().solve();
    }
}


using System;
using System.Collections.Generic;
using System.Text;

namespace codeforces
{
    class C
    {
        static CodeforcesUtils CF = new CodeforcesUtils(
@"
0 0 0 1
0 1 0 2
0 2 0 3
0 3 0 0
");

        static void Main(string[] args)
        {
            bool b = true;
            Dictionary<string, int> c = new Dictionary<string, int>();
            List<int> xs = new List<int>();
            List<int> ys = new List<int>();
            for (int i = 0;i<4;i++)
            {
                string[] ss  = CF.ReadLine().Split(' ');
                int x1 = int.Parse(ss[0]);
                int y1 = int.Parse(ss[1]);
                int x2 = int.Parse(ss[2]);
                int y2 = int.Parse(ss[3]);

                if (!_l(x1, y1, x2, y2))
                {
                    b = false;
                    break;
                }

                string p1 = x1 +","+ y1;
                if (!c.ContainsKey(p1))
                    c.Add(p1, 0);
                c[p1]++;

                string p2 = x2 + "," + y2;
                if (!c.ContainsKey(p2))
                    c.Add(p2, 0);
                c[p2]++;

                if( !xs.Contains(x1) )
                    xs.Add(x1);
                if (!xs.Contains(x2))
                    xs.Add(x2);
                if (!ys.Contains(y1))
                    ys.Add(y1);
                if (!ys.Contains(y2))
                    ys.Add(y2);
            }

            if (b)
            {
                if (xs.Count != 2 || ys.Count != 2)
                    b = false;
                else if (c.Count != 4)
                    b = false;
                else
                {
                    foreach (int v in c.Values)
                    {
                        if (v != 2)
                        {
                            b=false;
                            break;
                        }
                    }
                }
            }

            if (b)
                CF.WriteLine("YES");
            else
                CF.WriteLine("NO");

        }

        static bool _l(int x1,int y1,int x2,int y2)
        {
            if( x1!=x2&&y1!=y2)
                return false;
            if (x1 == x2 && y1 == y2)
                return false;
            return true;
        }

        #region test

        class CodeforcesUtils
        {
            public string ReadLine()
            {
#if DEBUG
                if (_lines == null)
                {
                    _lines = new List<string>();
                    string[] ss = _test_input.Replace("\n", "").Split('\r');
                    for (int i = 0; i < ss.Length; i++)
                    {
                        if (
                            (i == 0 || i == ss.Length - 1) &&
                            ss[i].Length == 0
                            )
                            continue;

                        _lines.Add(ss[i]);
                    }
                }

                string s = null;
                if (_lines.Count > 0)
                {
                    s = _lines[0];
                    _lines.RemoveAt(0);
                }
                return s;
#else
            return Console.In.ReadLine();
#endif
            }

            public void WriteLine(object o)
            {
#if DEBUG
                System.Diagnostics.Trace.WriteLine(o);
#else
            Console.WriteLine(o);
#endif
            }

            public void Write(object o)
            {
#if DEBUG
                System.Diagnostics.Trace.Write(o);
#else
            Console.Write(o);
#endif
            }

            public CodeforcesUtils(string test_input)
            {
                _test_input = test_input;
            }

            string _test_input;

            List<string> _lines;
        }

        #endregion
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProgrammingContest.Codeforces.Round14
{
    class C
    {
        public static void Main()
        {
            long[] x1 = new long[4];
            long[] x2 = new long[4];
            long[] y1 = new long[4];
            long[] y2 = new long[4];
            for (int i = 0; i < 4; i++)
            {
                string[] s = Console.ReadLine().Split(' ');
                x1[i] = long.Parse(s[0]);
                y1[i] = long.Parse(s[1]);
                x2[i] = long.Parse(s[2]);
                y2[i] = long.Parse(s[3]);
            }
            long minX = Math.Min(x1.Min(), x2.Min());
            long maxX = Math.Max(x1.Max(), x2.Max());
            long minY = Math.Min(y1.Min(), y2.Min());
            long maxY = Math.Max(y1.Max(), y2.Max());

            if (minX == maxX && minY == maxY)
            {
                Console.WriteLine("NO");
                return;
            }

            int[] xPar = new int[4];
            int[] yPar = new int[4];
            int x = 0, y = 0;
            for (int i = 0; i < 4; i++)
            {
                if (x1[i] == x2[i])
                {
                    yPar[y++] = i;

                    if(y1[i] > y2[i])
                    {
                        long temp = y1[i];
                        y1[i] = y2[i];
                        y2[i] = temp;
                    }
                }
                else if (y1[i] == y2[i])
                {
                    xPar[x++] = i;

                    if(x1[i] > x2[i])
                    {
                        long temp = x1[i];
                        x1[i] = x2[i];
                        x2[i] = temp;
                    }
                }
                else
                {
                    Console.WriteLine("NO");
                    return;
                }
            }
            if (x != 2 || y != 2)
            {
                Console.WriteLine("NO");
                return;
            }

            if (x1[yPar[0]] > x1[yPar[1]])
            {
                int temp = yPar[0];
                yPar[0] = yPar[1];
                yPar[1] = temp;
            }

            if (y1[xPar[0]] > y1[xPar[1]])
            {
                int temp = xPar[0];
                xPar[0] = xPar[1];
                xPar[1] = temp;
            }
#if false
            Console.WriteLine("xPar[0]:({0},{2}) ({1},{3})", x1[xPar[0]], x2[xPar[0]], y1[xPar[0]], y2[xPar[0]]);
            Console.WriteLine("xPar[1]:({0},{2}) ({1},{3})", x1[xPar[1]], x2[xPar[1]], y1[xPar[1]], y2[xPar[1]]);
            Console.WriteLine("yPar[0]:({0},{2}) ({1},{3})", x1[yPar[0]], x2[yPar[0]], y1[yPar[0]], y2[yPar[0]]);
            Console.WriteLine("yPar[1]:({0},{2}) ({1},{3})", x1[yPar[1]], x2[yPar[1]], y1[yPar[1]], y2[yPar[1]]);
#endif
            if (x1[yPar[0]] == x1[xPar[0]] && x1[yPar[0]] == x1[xPar[1]] &&
                x1[yPar[1]] == x2[xPar[0]] && x1[yPar[1]] == x2[xPar[1]] &&
                y1[xPar[0]] == y1[yPar[0]] && y1[xPar[0]] == y1[yPar[1]] &&
                y1[xPar[1]] == y2[yPar[0]] && y1[xPar[1]] == y2[yPar[1]])
            {
                Console.WriteLine("YES");
            }
            else Console.WriteLine("NO");
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Codeforce
{

    class Printer
    {
        StringBuilder sb;

        public Printer()
        {
            sb = new StringBuilder();
        }

        public void WriteLine(string s)
        {
            sb.AppendLine(s);
        }
        public void WriteLine()
        {
            sb.AppendLine();
        }
        public void Write(string s)
        {
            sb.Append(s);
        }

        public void Print()
        {
            Console.Write(sb);
        }
    }

    class Program
    {
        static StreamReader input = new StreamReader(Console.OpenStandardInput());
        //static StreamWriter output = new StreamWriter(Console.OpenStandardOutput());

        static int nextInt()
        {
            int t = input.Read();
            while ((t < '0' || t > '9') && t != '-') t = input.Read();
            int sign = 1;
            if (t == '-')
            {
                sign = -1;
                t = input.Read();
            }
            int x = 0;
            while (t >= '0' && t <= '9')
            {
                x *= 10;
                x += t - '0';
                t = input.Read();
            }
            return x * sign;
        }

        static int[] parseInt(string s)
        {
            string[] temp = s.Split(' ');
            int[] res = new int[temp.Length];
            for (int i = 0; i < temp.Length; i++)
            {
                res[i] = Convert.ToInt32(temp[i]);
            }
            return res;
        }

        static double Dist(double x1, double y1, double x2, double y2)
        {
            return Math.Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
        }
        struct Point
        {
            public double x { get; set; }
            public double y { get; set; }

            public Point(double _x, double _y)
                : this()
            {
                x = _x;
                y = _y;
            }
            public double DistTo(Point p2)
            {
                return Dist(x, y, p2.x, p2.y);
            }
        }

        class Segment
        {
            public Point first { get; set; }
            public Point last { get; set; }

            public Segment()
            {

            }
            public Segment(Point f, Point l)
            {
                first = f;
                last = l;
            }

            public void Swap()
            {
                Point tmp = first;
                first = last;
                last = tmp;
            }
        }
        static bool[] used = new bool[4];

        static bool isP(int i, Segment[] P, int length)
        {
            if (!(P[i].first.x == P[i].last.x || P[i].first.y == P[i].last.y) || length > 5)
                return false;
            if (length == 5 && i == 0)
                return true;

            int j = i + 1 < 4 ? i + 1 : 0;
            if ((!used[j] || j == 0) && P[i].last.x == P[j].first.x && P[i].last.y == P[j].first.y && (P[j].first.x == P[j].last.x || P[j].first.y == P[j].last.y))
            {
                used[j] = true;
                return isP(j, P, length + 1);
            }

            return false;
        }

        static void Main(string[] args)
        {
            Printer printer = new Printer();

            List<Segment> P = new List<Segment>();

            Segment[] S = new Segment[4];

            for (int i = 0; i < 4; i++)
            {
                var tmp = parseInt(Console.ReadLine());

                if (tmp[1] == tmp[3])
                {
                    if (tmp[2] == tmp[0])
                    {
                        Console.WriteLine("NO");
                        return;
                    }
                    if (S[0] != null && S[0].first.y < tmp[1])
                    {
                        S[2] = S[0];
                        S[0] = new Segment(new Point(tmp[0], tmp[1]), new Point(tmp[2], tmp[3]));
                    }
                    else if (S[0] != null && S[0].first.y >= tmp[1])
                    {
                        if (S[0].first.y == tmp[1])
                        {
                            Console.WriteLine("NO");
                            return;
                        }
                        S[2] = new Segment(new Point(tmp[0], tmp[1]), new Point(tmp[2], tmp[3]));
                    }
                    else if(S[0] == null)
                    {
                        S[0] = new Segment(new Point(tmp[0], tmp[1]), new Point(tmp[2], tmp[3]));
                    }
                }
                if (tmp[0] == tmp[2])
                {
                    if (tmp[1] == tmp[3])
                    {
                        Console.WriteLine("NO");
                        return;
                    }
                    if (S[1] != null && S[1].first.x < tmp[0])
                    {
                        S[3] = S[1];
                        S[1] = new Segment(new Point(tmp[0], tmp[1]), new Point(tmp[2], tmp[3]));
                    }
                    else if (S[1] != null && S[1].first.x >= tmp[0])
                    {
                        if (S[1].first.y == tmp[0])
                        {
                            Console.WriteLine("NO");
                            return;
                        }
                        S[3] = new Segment(new Point(tmp[0], tmp[1]), new Point(tmp[2], tmp[3]));
                    }
                    else if (S[1] == null)
                    {
                        S[1] = new Segment(new Point(tmp[0], tmp[1]), new Point(tmp[2], tmp[3]));
                    }
                }
                //P.Add(new Segment(new Point(tmp[0], tmp[1]), new Point(tmp[2], tmp[3])));
            }

            if (S[0].first.x > S[0].last.x)
                S[0].Swap();
            if (S[1].first.y < S[1].last.y)
                S[1].Swap();
            if (S[2].first.x < S[2].last.x)
                S[2].Swap();
            if (S[3].first.y > S[3].last.y)
                S[3].Swap();

            used[0] = true;
            bool tf = isP(0, S, 1);

            string res = tf ? "YES" : "NO";

            printer.WriteLine(res);

            printer.Print();

        }
    }
}


using System;
using System.Collections.Generic;
using System.Text;

namespace codeforces
{
    class C
    {
        static CodeforcesUtils CF = new CodeforcesUtils(
@"
0 0 0 3
2 0 0 0
2 2 2 0
0 2 2 2
");

        static void Main(string[] args)
        {
            bool b = true;
            Dictionary<string, int> c = new Dictionary<string, int>();
            for (int i = 0;i<4;i++)
            {
                string[] ss  = CF.ReadLine().Split(' ');
                int x1 = int.Parse(ss[0]);
                int y1 = int.Parse(ss[1]);
                int x2 = int.Parse(ss[2]);
                int y2 = int.Parse(ss[3]);

                if (!_l(x1, y1, x2, y2))
                {
                    b = false;
                    break;
                }

                string p1 = x1 +","+ y1;
                if (!c.ContainsKey(p1))
                    c.Add(p1, 0);
                c[p1]++;

                string p2 = x2 + "," + y2;
                if (!c.ContainsKey(p2))
                    c.Add(p2, 0);
                c[p2]++;
            }

            if (b)
            {
                if (c.Count != 4)
                    b = false;
                else
                {
                    foreach (int v in c.Values)
                    {
                        if (v != 2)
                        {
                            b=false;
                            break;
                        }
                    }
                }
            }

            if (b)
                CF.WriteLine("YES");
            else
                CF.WriteLine("NO");

        }

        static bool _l(int x1,int y1,int x2,int y2)
        {
            if( x1!=x2&&y1!=y2)
                return false;
            if (x1 == x2 && y1 == y2)
                return false;
            return true;
        }

        #region test

        class CodeforcesUtils
        {
            public string ReadLine()
            {
#if DEBUG
                if (_lines == null)
                {
                    _lines = new List<string>();
                    string[] ss = _test_input.Replace("\n", "").Split('\r');
                    for (int i = 0; i < ss.Length; i++)
                    {
                        if (
                            (i == 0 || i == ss.Length - 1) &&
                            ss[i].Length == 0
                            )
                            continue;

                        _lines.Add(ss[i]);
                    }
                }

                string s = null;
                if (_lines.Count > 0)
                {
                    s = _lines[0];
                    _lines.RemoveAt(0);
                }
                return s;
#else
            return Console.In.ReadLine();
#endif
            }

            public void WriteLine(object o)
            {
#if DEBUG
                System.Diagnostics.Trace.WriteLine(o);
#else
            Console.WriteLine(o);
#endif
            }

            public void Write(object o)
            {
#if DEBUG
                System.Diagnostics.Trace.Write(o);
#else
            Console.Write(o);
#endif
            }

            public CodeforcesUtils(string test_input)
            {
                _test_input = test_input;
            }

            string _test_input;

            List<string> _lines;
        }

        #endregion
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Contest_14
{
    class Program
    {
        static void A()
        {
            var t = Console.ReadLine().Split(' ');
            int n = int.Parse(t[0]);
            int m = int.Parse(t[1]);

            int x1 = int.MaxValue, x2 = int.MinValue, y1 = int.MaxValue, y2 = int.MinValue;
            List<string> a = new List<string>();
            for (int i = 0; i < n; i++)
            {
                string s = Console.ReadLine();
                a.Add(s);
                for (int j = 0; j < m; j++)
                {
                    if (s[j] == '*')
                    {
                        if (x1 > i)
                            x1 = i;
                        if (x2 < i)
                            x2 = i;
                        if (y1 > j)
                            y1 = j;
                        if (y2 < j)
                            y2 = j;
                    }
                }
            }

            for (int i = x1; i <= x2; i++)
            {
                for (int j = y1; j <= y2; j++)
                {
                    Console.Write(a[i][j]);
                }
                Console.WriteLine();
            }
        }

        static void B()
        {
            var t = Console.ReadLine().Split(' ');
            int n = int.Parse(t[0]);
            int x = int.Parse(t[1]);

            int min = int.MaxValue;
            int max = int.MinValue;
            int[] a = new int[1001];
            for (int i = 0; i < n; i++)
            {
                t = Console.ReadLine().Split(' ');
                int k = int.Parse(t[0]);
                int l = int.Parse(t[1]);

                if (k > l)
                {
                    int q = k;
                    k = l;
                    l = q;
                }
                if (i == 0)
                {
                    min = k;
                    max = l;
                    continue;
                }
                if (k > min)
                {
                    min = k;
                }
                if (l < max)
                    max = l;
            }
            if (max < min)
            {
                Console.WriteLine(-1);
                return;
            }
            if ((x >= min) && (x <= max))
                Console.WriteLine(0);
            else
                Console.WriteLine(Math.Min(Math.Abs(min - x), Math.Abs(max - x)));
        }

        class Point : IComparer<Point>
        {
            public int x;
            public int y;

            public Point(int x, int y)
            {
                this.x = x;
                this.y = y;
            }

            public int Compare(Point p1, Point p2)
            {
                if (p1.x != p2.x)
                    return p1.x.CompareTo(p2.x);
                else
                    return p1.y.CompareTo(p2.y);
            }

            public bool isGood (Point p)
            {
                if ((x == p.x) && (y != p.y))
                    return true;
                if ((y == p.y) && (x != p.x))
                    return true;
                return false;
            }

            public void deleteInList(List<Point> b)
            {
                for (int j = 0; j < b.Count; j++)
                {
                    Point temp = b[j];
                    if ((temp.x == this.x) && (temp.y == this.y))
                    {
                        b.RemoveAt(j);
                        break;
                    }
                }

            }

        }

        static void C()
        {
            List<int[]> a = new List<int[]>();
            for (int i = 0; i < 4; i++)
            {
                var t = Console.ReadLine().Split(' ');
                a.Add(new int[] {int.Parse(t[0]),int.Parse(t[1]),int.Parse(t[2]),int.Parse(t[3])});
            }

            List<Point> b = new List<Point>();

            int xl = int.MaxValue, yl = int.MinValue, xr = int.MinValue, yr = int.MaxValue;

            for (int i = 0; i < 4; i++)
            {
                int[] t = a[i];
                Point l1 = new Point(t[0], t[1]);
                Point l2 = new Point(t[2], t[3]);
                b.Add(l1);
                b.Add(l2);
                if (t[0] < xl)
                    xl = t[0];
                if (t[1] > yl)
                    yl = t[1];
                if (t[2] > xr)
                    xr = t[2];
                if (t[3] < yr)
                    yr = t[3];
                if (!l1.isGood(l2))
                {
                    Console.WriteLine("NO");
                    return;
                }
            }

            Point p1 = new Point(xl, yl);
            Point p2 = new Point(xr, yr);

            for (int i = 0; i < 2; i++)
            {
                p1.deleteInList(b);
                p2.deleteInList(b);
                new Point(p1.x, p2.y).deleteInList(b);
                new Point(p2.x, p1.y).deleteInList(b);
            }
            if (b.Count > 0)
                Console.WriteLine("NO");
            else Console.WriteLine("YES");
        }

        static void Main(string[] args)
        {
            //Console.SetIn(new StreamReader(@"C:\1.txt"));
            C();
        }
    }
}


using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.IO;

class Program
{
    class Point: IComparable<Point>
    {
        public int x, y;
        public Point(int x, int y)
        {
            this.x = x;
            this.y = y;
        }
        public int CompareTo(Point other)
        {
            if (other.x != x)
                return x - other.x;
            else
                return y - other.y;
        }
        public override bool Equals(object obj)
        {
            Point other = (Point)obj;
            return other.x == x && other.y == y;
        }
    }
    class Seg
    {
        public Point a, b;
        public Seg(Point a, Point b)
        {
            this.a = a;
            this.b = b;
        }
        public void revert()
        {
            Point temp = a;
            a = b;
            b = temp;
        }
    }
    void solve()
    {
        Seg[] seg = new Seg[4];
        for (int i = 0; i < 4; i++)
        {
            seg[i] = new Seg(new Point(nextInt(), nextInt()), new Point(nextInt(), nextInt()));
        }
        List<Seg> vertical = new List<Seg>();
        List<Seg> horizontal = new List<Seg>();
        foreach (Seg s in seg)
        {
            if (s.a.x == s.b.x)
            {
                vertical.Add(s);
            }
            else if (s.a.y == s.b.y)
            {
                horizontal.Add(s);
            }
            else
            {
                Console.WriteLine("NO");
                return;
            }
        }
        if (vertical.Count < 2 || horizontal.Count < 2)
        {
            Console.WriteLine("NO");
            return;
        }
        foreach (Seg s in vertical)
        {
            if (s.a.y > s.b.y)
                s.revert();
        }
        foreach (Seg s in horizontal)
        {
            if (s.a.x < s.b.y)
                s.revert();
        }
        int height1 = vertical[0].b.y - vertical[0].a.y;
        int height2 = vertical[1].b.y - vertical[1].a.y;
        int width1 = horizontal[0].b.x - horizontal[0].a.x;
        int width2 = horizontal[1].b.x - horizontal[1].a.x;
        if (height1 != height2 || width1 != width2 || height1==0 ||  width1==0)
        {
            Console.WriteLine("NO");
            return;
        }
        if (vertical[0].a.x > vertical[1].a.x)
        {
            Seg temp = vertical[0];
            vertical[0] = vertical[1];
            vertical[1] = temp;
        }
        if (horizontal[0].a.y > horizontal[1].a.y)
        {
            Seg temp = horizontal[0];
            horizontal[0] = horizontal[1];
            horizontal[1] = temp;
        }
        if (!vertical[0].a.Equals(horizontal[0].a))
        {
            Console.WriteLine("NO");
            return;
        }
        if (!vertical[0].b.Equals(horizontal[1].a))
        {
            Console.WriteLine("NO");
            return;
        }
        if (!vertical[1].a.Equals(horizontal[0].b))
        {
            Console.WriteLine("NO");
            return;
        }
        if (!vertical[1].b.Equals(horizontal[1].b))
        {
            Console.WriteLine("NO");
            return;
        }
        Console.WriteLine("YES");

    }

    //

    string[] inputLine = new string[0];
    int inputInd = 0;
    string nextLine()
    {
        return Console.ReadLine();
    }
    void readInput()
    {
        if (inputInd != inputLine.Length)
            throw new Exception();
        inputInd = 0;
        inputLine = Console.ReadLine().Split();

    }
    int nextInt()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return int.Parse(inputLine[inputInd++]);
    }
    long nextLong()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return long.Parse(inputLine[inputInd++]);
    }
    double nextDouble()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return double.Parse(inputLine[inputInd++]);
    }
    string nextString()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return inputLine[inputInd++];
    }
    static void Main(string[] args)
    {
        new Program().solve();
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace code_29
{
    class Program
    {
        static void Main(string[] args)
        {
            bool b=false;
            int[][] mas = new int[4][];
            for (int i = 0; i < 4; i++)
            {
                string s = Console.ReadLine();
                mas[i] = (from v in s.Split(' ') let q = int.Parse(v) select q).ToArray();
            }
            for (int i = 0; i < 4; i++)//point
            {
                if (mas[i][0] == mas[i][2] && mas[i][1] == mas[i][3])
                    b = true;

            }
            if (b) { Console.WriteLine("NO1"); return; }
            for (int i = 0; i < 4; i++)//parall
            {
                if (mas[i][0] != mas[i][2] && mas[i][1] != mas[i][3])
                    b = true;
            }
            if (b) { Console.WriteLine("NO2"); return; }
            int[,] connect = new int[4, 4];
            for (int i = 0; i < 4; i++)
                for (int j = 0; j < 4; j++)
                {
                    connect[i, j] = -1;
                }

            for (int i = 0; i < 4; i++)//connect
            {
                bool zapis1 = false;
                bool zapis2 = false;

                for (int j = 0; j < 4; j++)
                {
                    if (i == j) continue;
                    if (mas[i][0] == mas[j][0] && mas[i][1] == mas[j][1])
                    {
                        if (connect[j, 2] == i) b = true;

                        if (connect[j, 0] == -1)
                        {
                            connect[j, 0] = i;
                            connect[j, 1] = i;
                            zapis1 = true;
                        }
                        else
                            b = true;
                    }
                    else
                        if (mas[i][0] == mas[j][2] && mas[i][1] == mas[j][3])
                        {
                            if (connect[j, 0] == i) b = true;

                            if (connect[j, 2] == -1)
                            {
                                connect[j, 2] = i;
                                connect[j, 3] = i;
                                zapis1 = true;
                            }
                            else
                                b = true;
                        }

                    if (mas[i][2] == mas[j][0] && mas[i][3] == mas[j][1])
                    {
                        if (connect[j, 2] == i) b = true;
                        if (connect[j, 0] == -1)
                        {
                            connect[j, 0] = i;
                            connect[j, 1] = i;
                            zapis2 = true;
                        }
                        else
                            b = true;
                    }
                    else
                        if (mas[i][2] == mas[j][2] && mas[i][3] == mas[j][3])
                        {
                            if (connect[j, 0] == i) b = true;

                            if (connect[j, 2] == -1)
                            {
                                connect[j, 2] = i;
                                connect[j, 3] = i;
                                zapis2 = true;
                            }
                            else
                                b = true;
                        }

                }
                if (zapis1 && zapis2) { }
                else b = true;
            }
            if (b)  Console.WriteLine("NO3");
            else Console.WriteLine("YES");

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Codeforce
{

    class Printer
    {
        StringBuilder sb;

        public Printer()
        {
            sb = new StringBuilder();
        }

        public void WriteLine(string s)
        {
            sb.AppendLine(s);
        }
        public void WriteLine()
        {
            sb.AppendLine();
        }
        public void Write(string s)
        {
            sb.Append(s);
        }

        public void Print()
        {
            Console.Write(sb);
        }
    }

    class Program
    {
        static StreamReader input = new StreamReader(Console.OpenStandardInput());
        //static StreamWriter output = new StreamWriter(Console.OpenStandardOutput());

        static int nextInt()
        {
            int t = input.Read();
            while ((t < '0' || t > '9') && t != '-') t = input.Read();
            int sign = 1;
            if (t == '-')
            {
                sign = -1;
                t = input.Read();
            }
            int x = 0;
            while (t >= '0' && t <= '9')
            {
                x *= 10;
                x += t - '0';
                t = input.Read();
            }
            return x * sign;
        }

        static int[] parseInt(string s)
        {
            string[] temp = s.Split(' ');
            int[] res = new int[temp.Length];
            for (int i = 0; i < temp.Length; i++)
            {
                res[i] = Convert.ToInt32(temp[i]);
            }
            return res;
        }

        static double Dist(double x1, double y1, double x2, double y2)
        {
            return Math.Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
        }
        struct Point
        {
            public double x { get; set; }
            public double y { get; set; }

            public Point(double _x, double _y)
                : this()
            {
                x = _x;
                y = _y;
            }
            public double DistTo(Point p2)
            {
                return Dist(x, y, p2.x, p2.y);
            }
        }

        class Segment
        {
            public Point first { get; set; }
            public Point last { get; set; }

            public Segment()
            {

            }
            public Segment(Point f, Point l)
            {
                first = f;
                last = l;
            }

            public void Swap()
            {
                Point tmp = first;
                first = last;
                last = tmp;
            }
        }
        static bool[] used = new bool[4];

        static bool isP(int i, Segment[] P, int length)
        {
            if (!(P[i].first.x == P[i].last.x || P[i].first.y == P[i].last.y) || length > 5)
                return false;
            if (length == 5 && i == 0)
                return true;

            int j = i + 1 < 4 ? i + 1 : 0;
            if ((!used[j] || j == 0) && P[i].last.x == P[j].first.x && P[i].last.y == P[j].first.y && (P[j].first.x == P[j].last.x || P[j].first.y == P[j].last.y))
            {
                used[j] = true;
                return isP(j, P, length + 1);
            }

            return false;
        }

        static void Main(string[] args)
        {
            Printer printer = new Printer();

            List<Segment> P = new List<Segment>();

            Segment[] S = new Segment[4];

            for (int i = 0; i < 4; i++)
            {
                var tmp = parseInt(Console.ReadLine());

                if (tmp[1] == tmp[3])
                {
                    if (tmp[2] == tmp[0])
                    {
                        Console.WriteLine("NO");
                        return;
                    }
                    if (S[0] != null && S[0].first.y < tmp[1])
                    {
                        S[2] = S[0];
                        S[0] = new Segment(new Point(tmp[0], tmp[1]), new Point(tmp[2], tmp[3]));
                    }
                    else if (S[0] != null && S[0].first.y >= tmp[1])
                    {
                        S[2] = new Segment(new Point(tmp[0], tmp[1]), new Point(tmp[2], tmp[3]));
                    }
                    else if(S[0] == null)
                    {
                        S[0] = new Segment(new Point(tmp[0], tmp[1]), new Point(tmp[2], tmp[3]));
                    }
                }
                if (tmp[0] == tmp[2])
                {
                    if (tmp[1] == tmp[3])
                    {
                        Console.WriteLine("NO");
                        return;
                    }
                    if (S[1] != null && S[1].first.x < tmp[0])
                    {
                        S[3] = S[1];
                        S[1] = new Segment(new Point(tmp[0], tmp[1]), new Point(tmp[2], tmp[3]));
                    }
                    else if (S[1] != null && S[1].first.x >= tmp[0])
                    {
                        S[3] = new Segment(new Point(tmp[0], tmp[1]), new Point(tmp[2], tmp[3]));
                    }
                    else if (S[1] == null)
                    {
                        S[1] = new Segment(new Point(tmp[0], tmp[1]), new Point(tmp[2], tmp[3]));
                    }
                }
                //P.Add(new Segment(new Point(tmp[0], tmp[1]), new Point(tmp[2], tmp[3])));
            }

            if (S[0].first.x > S[0].last.x)
                S[0].Swap();
            if (S[1].first.y < S[1].last.y)
                S[1].Swap();
            if (S[2].first.x < S[2].last.x)
                S[2].Swap();
            if (S[3].first.y > S[3].last.y)
                S[3].Swap();

            used[0] = true;
            bool tf = isP(0, S, 1);

            string res = tf ? "YES" : "NO";

            printer.WriteLine(res);

            printer.Print();

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Codeforce
{

    class Printer
    {
        StringBuilder sb;

        public Printer()
        {
            sb = new StringBuilder();
        }

        public void WriteLine(string s)
        {
            sb.AppendLine(s);
        }
        public void WriteLine()
        {
            sb.AppendLine();
        }
        public void Write(string s)
        {
            sb.Append(s);
        }

        public void Print()
        {
            Console.Write(sb);
        }
    }

    class Program
    {
        static StreamReader input = new StreamReader(Console.OpenStandardInput());
        //static StreamWriter output = new StreamWriter(Console.OpenStandardOutput());

        static int nextInt()
        {
            int t = input.Read();
            while ((t < '0' || t > '9') && t != '-') t = input.Read();
            int sign = 1;
            if (t == '-')
            {
                sign = -1;
                t = input.Read();
            }
            int x = 0;
            while (t >= '0' && t <= '9')
            {
                x *= 10;
                x += t - '0';
                t = input.Read();
            }
            return x * sign;
        }

        static int[] parseInt(string s)
        {
            string[] temp = s.Split(' ');
            int[] res = new int[temp.Length];
            for (int i = 0; i < temp.Length; i++)
            {
                res[i] = Convert.ToInt32(temp[i]);
            }
            return res;
        }

        static double Dist(double x1, double y1, double x2, double y2)
        {
            return Math.Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
        }
        struct Point
        {
            public double x { get; set; }
            public double y { get; set; }

            public Point(double _x, double _y)
                : this()
            {
                x = _x;
                y = _y;
            }
            public double DistTo(Point p2)
            {
                return Dist(x, y, p2.x, p2.y);
            }
        }

        class Segment
        {
            public Point first { get; set; }
            public Point last { get; set; }

            public Segment()
            {

            }
            public Segment(Point f, Point l)
            {
                first = f;
                last = l;
            }

            public void Swap()
            {
                Point tmp = first;
                first = last;
                last = tmp;
            }
        }
        static bool[] used = new bool[4];

        static bool isP(int i, Segment[] P, int length)
        {
            if (!(P[i].first.x == P[i].last.x || P[i].first.y == P[i].last.y))
                return false;
            if (length == 5 && i == 0)
                return true;

            int j = i + 1 < 4 ? i + 1 : 0;
            if ((!used[j] || j == 0) && P[i].last.x == P[j].first.x && P[i].last.y == P[j].first.y && (P[j].first.x == P[j].last.x || P[j].first.y == P[j].last.y))
            {
                used[j] = true;
                return isP(j, P, length + 1);
            }

            return false;
        }

        static void Main(string[] args)
        {
            Printer printer = new Printer();

            List<Segment> P = new List<Segment>();

            Segment[] S = new Segment[4];

            for (int i = 0; i < 4; i++)
            {
                var tmp = parseInt(Console.ReadLine());

                if (tmp[1] == tmp[3])
                {
                    if (S[0] != null && S[0].first.y < tmp[1])
                    {
                        S[2] = S[0];
                        S[0] = new Segment(new Point(tmp[0], tmp[1]), new Point(tmp[2], tmp[3]));
                    }
                    else if (S[0] != null && S[0].first.y > tmp[1])
                    {
                        S[2] = new Segment(new Point(tmp[0], tmp[1]), new Point(tmp[2], tmp[3]));
                    }
                    else if(S[0] == null)
                    {
                        S[0] = new Segment(new Point(tmp[0], tmp[1]), new Point(tmp[2], tmp[3]));
                    }
                }
                if (tmp[0] == tmp[2])
                {
                    if (S[1] != null && S[1].first.x < tmp[0])
                    {
                        S[3] = S[1];
                        S[1] = new Segment(new Point(tmp[0], tmp[1]), new Point(tmp[2], tmp[3]));
                    }
                    else if (S[1] != null && S[1].first.x > tmp[0])
                    {
                        S[3] = new Segment(new Point(tmp[0], tmp[1]), new Point(tmp[2], tmp[3]));
                    }
                    else if (S[1] == null)
                    {
                        S[1] = new Segment(new Point(tmp[0], tmp[1]), new Point(tmp[2], tmp[3]));
                    }
                }
                //P.Add(new Segment(new Point(tmp[0], tmp[1]), new Point(tmp[2], tmp[3])));
            }

            if (S[0].first.x > S[0].last.x)
                S[0].Swap();
            if (S[1].first.y < S[1].last.y)
                S[1].Swap();
            if (S[2].first.x < S[2].last.x)
                S[2].Swap();
            if (S[3].first.y > S[3].last.y)
                S[3].Swap();

            used[0] = true;
            bool tf = isP(0, S, 1);

            string res = tf ? "YES" : "NO";

            printer.WriteLine(res);

            printer.Print();

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Contest_14
{
    class Program
    {
        static void A()
        {
            var t = Console.ReadLine().Split(' ');
            int n = int.Parse(t[0]);
            int m = int.Parse(t[1]);

            int x1 = int.MaxValue, x2 = int.MinValue, y1 = int.MaxValue, y2 = int.MinValue;
            List<string> a = new List<string>();
            for (int i = 0; i < n; i++)
            {
                string s = Console.ReadLine();
                a.Add(s);
                for (int j = 0; j < m; j++)
                {
                    if (s[j] == '*')
                    {
                        if (x1 > i)
                            x1 = i;
                        if (x2 < i)
                            x2 = i;
                        if (y1 > j)
                            y1 = j;
                        if (y2 < j)
                            y2 = j;
                    }
                }
            }

            for (int i = x1; i <= x2; i++)
            {
                for (int j = y1; j <= y2; j++)
                {
                    Console.Write(a[i][j]);
                }
                Console.WriteLine();
            }
        }

        static void B()
        {
            var t = Console.ReadLine().Split(' ');
            int n = int.Parse(t[0]);
            int x = int.Parse(t[1]);

            int min = int.MaxValue;
            int max = int.MinValue;
            int[] a = new int[1001];
            for (int i = 0; i < n; i++)
            {
                t = Console.ReadLine().Split(' ');
                int k = int.Parse(t[0]);
                int l = int.Parse(t[1]);

                if (k > l)
                {
                    int q = k;
                    k = l;
                    l = q;
                }
                if (i == 0)
                {
                    min = k;
                    max = l;
                    continue;
                }
                if (k > min)
                {
                    min = k;
                }
                if (l < max)
                    max = l;
            }
            if (max < min)
            {
                Console.WriteLine(-1);
                return;
            }
            if ((x >= min) && (x <= max))
                Console.WriteLine(0);
            else
                Console.WriteLine(Math.Min(Math.Abs(min - x), Math.Abs(max - x)));
        }

        class Point : IComparer<Point>
        {
            public int x;
            public int y;

            public Point(int x, int y)
            {
                this.x = x;
                this.y = y;
            }

            public int Compare(Point p1, Point p2)
            {
                if (p1.x != p2.x)
                    return p1.x.CompareTo(p2.x);
                else
                    return p1.y.CompareTo(p2.y);
            }

            public bool isGood (Point p)
            {
                if ((x == p.x) && (y != p.y))
                    return true;
                if ((y == p.y) && (x != p.x))
                    return true;
                return false;
            }

            public void deleteInList(List<Point> b)
            {
                for (int j = 0; j < b.Count; j++)
                {
                    Point temp = b[j];
                    if ((temp.x == this.x) && (temp.y == this.y))
                    {
                        b.RemoveAt(j);
                        break;
                    }
                }

            }

        }

        static void C()
        {
            List<int[]> a = new List<int[]>();
            for (int i = 0; i < 4; i++)
            {
                var t = Console.ReadLine().Split(' ');
                a.Add(new int[] {int.Parse(t[0]),int.Parse(t[1]),int.Parse(t[2]),int.Parse(t[3])});
            }

            List<Point> b = new List<Point>();

            int xl = int.MaxValue, yl = int.MinValue, xr = int.MinValue, yr = int.MaxValue;

            for (int i = 0; i < 4; i++)
            {
                int[] t = a[i];
                Point l1 = new Point(t[0], t[1]);
                Point l2 = new Point(t[2], t[3]);
                b.Add(l1);
                b.Add(l2);
                if (t[0] < xl)
                    xl = t[0];
                if (t[1] > yl)
                    yl = t[1];
                if (t[2] > xr)
                    xr = t[2];
                if (t[3] < yr)
                    yr = t[3];
                if (!l1.isGood(l2))
                {
                    Console.WriteLine("NO");
                    return;
                }
            }

            Point p1 = new Point(xl, yl);
            Point p2 = new Point(xr, yr);

            for (int i = 0; i < 2; i++)
            {
                p1.deleteInList(b);
                p2.deleteInList(b);
                new Point(p1.x, p2.y).deleteInList(b);
                new Point(p2.x, p1.y).deleteInList(b);
            }
            if (b.Count > 0)
                Console.WriteLine("NO");
            else Console.WriteLine("YES");
        }

        static void Main(string[] args)
        {
            Console.SetIn(new StreamReader(@"C:\1.txt"));
            C();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Contest_14
{
    class Program
    {
        static void A()
        {
            var t = Console.ReadLine().Split(' ');
            int n = int.Parse(t[0]);
            int m = int.Parse(t[1]);

            int x1 = int.MaxValue, x2 = int.MinValue, y1 = int.MaxValue, y2 = int.MinValue;
            List<string> a = new List<string>();
            for (int i = 0; i < n; i++)
            {
                string s = Console.ReadLine();
                a.Add(s);
                for (int j = 0; j < m; j++)
                {
                    if (s[j] == '*')
                    {
                        if (x1 > i)
                            x1 = i;
                        if (x2 < i)
                            x2 = i;
                        if (y1 > j)
                            y1 = j;
                        if (y2 < j)
                            y2 = j;
                    }
                }
            }

            for (int i = x1; i <= x2; i++)
            {
                for (int j = y1; j <= y2; j++)
                {
                    Console.Write(a[i][j]);
                }
                Console.WriteLine();
            }
        }

        static void B()
        {
            var t = Console.ReadLine().Split(' ');
            int n = int.Parse(t[0]);
            int x = int.Parse(t[1]);

            int min = int.MaxValue;
            int max = int.MinValue;
            int[] a = new int[1001];
            for (int i = 0; i < n; i++)
            {
                t = Console.ReadLine().Split(' ');
                int k = int.Parse(t[0]);
                int l = int.Parse(t[1]);

                if (k > l)
                {
                    int q = k;
                    k = l;
                    l = q;
                }
                if (i == 0)
                {
                    min = k;
                    max = l;
                    continue;
                }
                if (k > min)
                {
                    min = k;
                }
                if (l < max)
                    max = l;
            }
            if (max < min)
            {
                Console.WriteLine(-1);
                return;
            }
            if ((x >= min) && (x <= max))
                Console.WriteLine(0);
            else
                Console.WriteLine(Math.Min(Math.Abs(min - x), Math.Abs(max - x)));
        }

        class Point : IComparer<Point>
        {
            public int x;
            public int y;

            public Point(int x, int y)
            {
                this.x = x;
                this.y = y;
            }

            public int Compare(Point p1, Point p2)
            {
                if (p1.x != p2.x)
                    return p1.x.CompareTo(p2.x);
                else
                    return p1.y.CompareTo(p2.y);
            }

            public bool isGood (Point p)
            {
                if ((x == p.x) && (y != p.y))
                    return true;
                if ((y == p.y) && (x != p.x))
                    return true;
                return false;
            }

            public void deleteInList(List<Point> b)
            {
                for (int j = 0; j < b.Count; j++)
                {
                    Point temp = b[j];
                    if ((temp.x == this.x) && (temp.y == this.y))
                    {
                        b.RemoveAt(j);
                        break;
                    }
                }

            }

        }

        static void C()
        {
            List<int[]> a = new List<int[]>();

            for (int i = 0; i < 4; i++)
            {
                var t = Console.ReadLine().Split(' ');
                var t1 = new int[] { int.Parse(t[0]), int.Parse(t[1]), int.Parse(t[2]), int.Parse(t[3]) };
                for (int j = 0; j < a.Count; j++)
                {
                    var k = a[j];

                    if ((k[0] == t1[0]) && (k[1] == t1[1]) && (k[2] == t1[2]) && (k[3] == t1[3]))
                    {
                        Console.WriteLine("NO");
                        return;
                    }

                    if ((k[2] == t1[0]) && (k[3] == t1[1]) && (k[0] == t1[2]) && (k[1] == t1[3]))
                    {
                        Console.WriteLine("NO");
                        return;
                    }
                }
                a.Add(t1);

            }

            List<Point> b = new List<Point>();

            int xl = int.MaxValue, yl = int.MinValue, xr = int.MinValue, yr = int.MaxValue;

            for (int i = 0; i < 4; i++)
            {
                int[] t = a[i];
                Point l1 = new Point(t[0], t[1]);
                Point l2 = new Point(t[2], t[3]);
                b.Add(l1);
                b.Add(l2);
                if (t[0] < xl)
                    xl = t[0];
                if (t[1] > yl)
                    yl = t[1];
                if (t[2] > xr)
                    xr = t[2];
                if (t[3] < yr)
                    yr = t[3];
                if (!l1.isGood(l2))
                {
                    Console.WriteLine("NO");
                    return;
                }
            }

            Point p1 = new Point(xl, yl);
            Point p2 = new Point(xr, yr);

            for (int i = 0; i < 2; i++)
            {
                p1.deleteInList(b);
                p2.deleteInList(b);
                new Point(p1.x, p2.y).deleteInList(b);
                new Point(p2.x, p1.y).deleteInList(b);
            }
            if (b.Count > 0)
                Console.WriteLine("NO");
            else Console.WriteLine("YES");
        }

        static void Main(string[] args)
        {
            Console.SetIn(new StreamReader(@"C:\1.txt"));
            C();
        }
    }
}


using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.IO;

class Program
{
    class Point: IComparable<Point>
    {
        public int x, y;
        public Point(int x, int y)
        {
            this.x = x;
            this.y = y;
        }
        public int CompareTo(Point other)
        {
            if (other.x != x)
                return x - other.x;
            else
                return y - other.y;
        }
        public override bool Equals(object obj)
        {
            Point other = (Point)obj;
            return other.x == x && other.y == y;
        }
    }
    class Seg
    {
        public Point a, b;
        public Seg(Point a, Point b)
        {
            this.a = a;
            this.b = b;
        }
        public void revert()
        {
            Point temp = a;
            a = b;
            b = temp;
        }
    }
    void solve()
    {
        Seg[] seg = new Seg[4];
        for (int i = 0; i < 4; i++)
        {
            seg[i] = new Seg(new Point(nextInt(), nextInt()), new Point(nextInt(), nextInt()));
        }
        List<Seg> vertical = new List<Seg>();
        List<Seg> horizontal = new List<Seg>();
        foreach (Seg s in seg)
        {
            if (s.a.x == s.b.x)
            {
                vertical.Add(s);
            }
            else if (s.a.y == s.b.y)
            {
                horizontal.Add(s);
            }
            else
            {
                Console.WriteLine("NO");
                return;
            }
        }
        if (vertical.Count < 2 || horizontal.Count < 2)
        {
            Console.WriteLine("NO");
            return;
        }
        foreach (Seg s in vertical)
        {
            if (s.a.y > s.b.y)
                s.revert();
        }
        foreach (Seg s in horizontal)
        {
            if (s.a.x > s.b.x)
                s.revert();
        }
        int height1 = vertical[0].b.y - vertical[0].a.y;
        int height2 = vertical[1].b.y - vertical[1].a.y;
        int width1 = horizontal[0].b.x - horizontal[0].a.x;
        int width2 = horizontal[1].b.x - horizontal[1].a.x;
        if (height1 != height2 || width1 != width2 || height1==0 ||  width1==0)
        {
            Console.WriteLine("NO");
            return;
        }
        if (vertical[0].a.x > vertical[1].a.x)
        {
            Seg temp = vertical[0];
            vertical[0] = vertical[1];
            vertical[1] = temp;
        }
        if (horizontal[0].a.y > horizontal[1].a.y)
        {
            Seg temp = horizontal[0];
            horizontal[0] = horizontal[1];
            horizontal[1] = temp;
        }
        if (!vertical[0].a.Equals(horizontal[0].a))
        {
            Console.WriteLine("NO");
            return;
        }
        if (!vertical[0].b.Equals(horizontal[1].a))
        {
            Console.WriteLine("NO");
            return;
        }
        if (!vertical[1].a.Equals(horizontal[0].b))
        {
            Console.WriteLine("NO");
            return;
        }
        if (!vertical[1].b.Equals(horizontal[1].b))
        {
            Console.WriteLine("NO");
            return;
        }
        Console.WriteLine("YES");

    }

    //

    string[] inputLine = new string[0];
    int inputInd = 0;
    string nextLine()
    {
        return Console.ReadLine();
    }
    void readInput()
    {
        if (inputInd != inputLine.Length)
            throw new Exception();
        inputInd = 0;
        inputLine = Console.ReadLine().Split();

    }
    int nextInt()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return int.Parse(inputLine[inputInd++]);
    }
    long nextLong()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return long.Parse(inputLine[inputInd++]);
    }
    double nextDouble()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return double.Parse(inputLine[inputInd++]);
    }
    string nextString()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return inputLine[inputInd++];
    }
    static void Main(string[] args)
    {
        new Program().solve();
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CodeForces
{
    static class Reader
    {
        public static int NextInt()
        {
            int ret = 0;
            char c;

            while (!char.IsDigit(c = (char)Console.Read()))
            {
                if (c == '-')
                    return -NextInt();
            }
            do
            {
                ret = ret * 10 + c - '0';
            } while (char.IsDigit(c = (char)Console.Read()));

            return ret;
        }

        public static double NextDouble()
        {
            double ret = 0;
            char c;

            while (!char.IsDigit(c = (char)Console.Read()))
            {
                if (c == '-')
                    return -NextDouble();
            }
            do
            {
                ret = ret * 10 + c - '0';
            } while (char.IsDigit(c = (char)Console.Read()));
            if (c != '.') return ret;

            double p10 = 0.1;
            while (char.IsDigit(c = (char)Console.Read()))
            {
                ret += p10 * (c - '0');
                p10 *= 0.1;
            }

            return ret;
        }

        public static string NextToken()
        {
            StringBuilder ret = new StringBuilder();
            char c;

            while (char.IsWhiteSpace(c = (char)Console.Read())) ;
            do
            {
                ret.Append(c);
            } while (!char.IsWhiteSpace(c = (char)Console.Read()));

            return ret.ToString();
        }
    }

    class Program
    {
        static void No()
        {
            Console.WriteLine("NO");
            Environment.Exit(0);
        }

        static void Main(string[] args)
        {
            List<List<int>> X, Y;

            X = new List<List<int>>();
            Y = new List<List<int>>();
            X.Add(new List<int>());
            Y.Add(new List<int>());

            for (int i = 0; i < 4; ++i)
            {
                int x1, y1, x2, y2;

                x1 = Reader.NextInt();
                y1 = Reader.NextInt();
                x2 = Reader.NextInt();
                y2 = Reader.NextInt();

                bool xeq = x1 == x2, yeq = y1 == y2;
                if (!(xeq ^ yeq))
                    No();
                else if (xeq)
                {
                    X[0].Add(x1);
                    Y.Add(new List<int>(new int[] { y1, y2 }));
                }
                else
                {
                    Y[0].Add(y1);
                    X.Add(new List<int>(new int[] { x1, x2 }));
                }
            }

            if (X.Count != 3 || Y.Count != 3)
                No();

            for (int i = 0; i < X.Count; ++i)
            {
                X[i].Sort();
                if (X[i].Count != X[0].Count)
                    No();
                for (int j = 0; j < X[i].Count; ++j)
                    if (X[i][j] != X[0][j])
                        No();
            }
            for (int i = 0; i < Y.Count; ++i)
            {
                Y[i].Sort();
                if (Y[i].Count != Y[0].Count)
                    No();
                for (int j = 0; j < Y[i].Count; ++j)
                    if (Y[i][j] != Y[0][j])
                        No();
            }

            Console.WriteLine("YES");
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProgrammingContest.Codeforces.Round14
{
    class C
    {
        public static void Main()
        {
            long[] x1 = new long[4];
            long[] x2 = new long[4];
            long[] y1 = new long[4];
            long[] y2 = new long[4];
            for (int i = 0; i < 4; i++)
            {
                string[] s = Console.ReadLine().Split(' ');
                x1[i] = long.Parse(s[0]);
                y1[i] = long.Parse(s[1]);
                x2[i] = long.Parse(s[2]);
                y2[i] = long.Parse(s[3]);
            }
            long minX = Math.Min(x1.Min(), x2.Min());
            long maxX = Math.Max(x1.Max(), x2.Max());
            long minY = Math.Min(y1.Min(), y2.Min());
            long maxY = Math.Max(y1.Max(), y2.Max());

            if (minX == maxX || minY == maxY)
            {
                Console.WriteLine("NO");
                return;
            }

            int[] xPar = new int[4];
            int[] yPar = new int[4];
            int x = 0, y = 0;
            for (int i = 0; i < 4; i++)
            {
                if (x1[i] == x2[i])
                {
                    yPar[y++] = i;

                    if(y1[i] > y2[i])
                    {
                        long temp = y1[i];
                        y1[i] = y2[i];
                        y2[i] = temp;
                    }
                }
                else if (y1[i] == y2[i])
                {
                    xPar[x++] = i;

                    if(x1[i] > x2[i])
                    {
                        long temp = x1[i];
                        x1[i] = x2[i];
                        x2[i] = temp;
                    }
                }
                else
                {
                    Console.WriteLine("NO");
                    return;
                }
            }
            if (x != 2 || y != 2)
            {
                Console.WriteLine("NO");
                return;
            }

            if (x1[yPar[0]] > x1[yPar[1]])
            {
                int temp = yPar[0];
                yPar[0] = yPar[1];
                yPar[1] = temp;
            }

            if (y1[xPar[0]] > y1[xPar[1]])
            {
                int temp = xPar[0];
                xPar[0] = xPar[1];
                xPar[1] = temp;
            }
#if false
            Console.WriteLine("xPar[0]:({0},{2}) ({1},{3})", x1[xPar[0]], x2[xPar[0]], y1[xPar[0]], y2[xPar[0]]);
            Console.WriteLine("xPar[1]:({0},{2}) ({1},{3})", x1[xPar[1]], x2[xPar[1]], y1[xPar[1]], y2[xPar[1]]);
            Console.WriteLine("yPar[0]:({0},{2}) ({1},{3})", x1[yPar[0]], x2[yPar[0]], y1[yPar[0]], y2[yPar[0]]);
            Console.WriteLine("yPar[1]:({0},{2}) ({1},{3})", x1[yPar[1]], x2[yPar[1]], y1[yPar[1]], y2[yPar[1]]);
#endif
            if (x1[yPar[0]] == x1[xPar[0]] && x1[yPar[0]] == x1[xPar[1]] &&
                x1[yPar[1]] == x2[xPar[0]] && x1[yPar[1]] == x2[xPar[1]] &&
                y1[xPar[0]] == y1[yPar[0]] && y1[xPar[0]] == y1[yPar[1]] &&
                y1[xPar[1]] == y2[yPar[0]] && y1[xPar[1]] == y2[yPar[1]])
            {
                Console.WriteLine("YES");
            }
            else Console.WriteLine("NO");
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace code_29
{
    class Program
    {
        static void Main(string[] args)
        {
            bool b=false;
            int[][] mas = new int[4][];
            for (int i = 0; i < 4; i++)
            {
                string s = Console.ReadLine();
                mas[i] = (from v in s.Split(' ') let q = int.Parse(v) select q).ToArray();
            }
            for (int i = 0; i < 4; i++)//point
            {
                if (mas[i][0] == mas[i][2] && mas[i][1] == mas[i][3])
                    b = true;

            }
            if (b) { Console.WriteLine("NO"); return; }
            for (int i = 0; i < 4; i++)//parall
            {
                if (mas[i][0] != mas[i][2] && mas[i][1] != mas[i][3])
                    b = true;
            }
            if (b) { Console.WriteLine("NO"); return; }

            int vert = 0;
            int gor = 0;
            for (int i = 0; i < 4; i++)
            {
                if (mas[i][0]==mas[i][2])
                    vert++;
                else gor++;
            }
            if(gor!=vert)
                 { Console.WriteLine("NO"); return; }

            int[,] connect = new int[4, 4];
            for (int i = 0; i < 4; i++)
                for (int j = 0; j < 4; j++)
                {
                    connect[i, j] = -1;
                }

            for (int i = 0; i < 4; i++)//connect
            {
                bool zapis1 = false;
                bool zapis2 = false;

                for (int j = 0; j < 4; j++)
                {
                    if (i == j) continue;
                    if (mas[i][0] == mas[j][0] && mas[i][1] == mas[j][1])
                    {
                        if (connect[j, 2] == i) b = true;

                        if (connect[j, 0] == -1)
                        {
                            connect[j, 0] = i;
                            connect[j, 1] = i;
                            zapis1 = true;
                        }
                        else
                            b = true;
                    }
                    else
                        if (mas[i][0] == mas[j][2] && mas[i][1] == mas[j][3])
                        {
                            if (connect[j, 0] == i) b = true;

                            if (connect[j, 2] == -1)
                            {
                                connect[j, 2] = i;
                                connect[j, 3] = i;
                                zapis1 = true;
                            }
                            else
                                b = true;
                        }

                    if (mas[i][2] == mas[j][0] && mas[i][3] == mas[j][1])
                    {
                        if (connect[j, 2] == i) b = true;
                        if (connect[j, 0] == -1)
                        {
                            connect[j, 0] = i;
                            connect[j, 1] = i;
                            zapis2 = true;
                        }
                        else
                            b = true;
                    }
                    else
                        if (mas[i][2] == mas[j][2] && mas[i][3] == mas[j][3])
                        {
                            if (connect[j, 0] == i) b = true;

                            if (connect[j, 2] == -1)
                            {
                                connect[j, 2] = i;
                                connect[j, 3] = i;
                                zapis2 = true;
                            }
                            else
                                b = true;
                        }

                }
                if (zapis1 && zapis2) { }
                else b = true;
            }
            if (b)  Console.WriteLine("NO");
            else Console.WriteLine("YES");

        }
    }
}


using System;
using System.Collections.Generic;
using System.Text;

namespace codeforces
{
    class C
    {
        static CodeforcesUtils CF = new CodeforcesUtils(
@"
0 0 0 1
0 0 0 1
1 0 1 1
1 0 1 1
");

        static void Main(string[] args)
        {
            bool b = true;
            Dictionary<string, int> c = new Dictionary<string, int>();
            List<int> xs = new List<int>();
            List<int> ys = new List<int>();
            int hc=0;
            for (int i = 0;i<4;i++)
            {
                string[] ss  = CF.ReadLine().Split(' ');
                int x1 = int.Parse(ss[0]);
                int y1 = int.Parse(ss[1]);
                int x2 = int.Parse(ss[2]);
                int y2 = int.Parse(ss[3]);

                if (!_l(x1, y1, x2, y2))
                {
                    b = false;
                    break;
                }

                if (x1 != x2)
                    hc++;

                string p1 = x1 +","+ y1;
                if (!c.ContainsKey(p1))
                    c.Add(p1, 0);
                c[p1]++;

                string p2 = x2 + "," + y2;
                if (!c.ContainsKey(p2))
                    c.Add(p2, 0);
                c[p2]++;

                if( !xs.Contains(x1) )
                    xs.Add(x1);
                if (!xs.Contains(x2))
                    xs.Add(x2);
                if (!ys.Contains(y1))
                    ys.Add(y1);
                if (!ys.Contains(y2))
                    ys.Add(y2);
            }

            if (b)
            {
                if (hc != 2)
                    b = false;
                else if (xs.Count != 2 || ys.Count != 2)
                    b = false;
                else if (c.Count != 4)
                    b = false;
                else
                {
                    foreach (int v in c.Values)
                    {
                        if (v != 2)
                        {
                            b=false;
                            break;
                        }
                    }
                }
            }

            if (b)
                CF.WriteLine("YES");
            else
                CF.WriteLine("NO");

        }

        static bool _l(int x1,int y1,int x2,int y2)
        {
            if( x1!=x2&&y1!=y2)
                return false;
            if (x1 == x2 && y1 == y2)
                return false;
            return true;
        }

        #region test

        class CodeforcesUtils
        {
            public string ReadLine()
            {
#if DEBUG
                if (_lines == null)
                {
                    _lines = new List<string>();
                    string[] ss = _test_input.Replace("\n", "").Split('\r');
                    for (int i = 0; i < ss.Length; i++)
                    {
                        if (
                            (i == 0 || i == ss.Length - 1) &&
                            ss[i].Length == 0
                            )
                            continue;

                        _lines.Add(ss[i]);
                    }
                }

                string s = null;
                if (_lines.Count > 0)
                {
                    s = _lines[0];
                    _lines.RemoveAt(0);
                }
                return s;
#else
            return Console.In.ReadLine();
#endif
            }

            public void WriteLine(object o)
            {
#if DEBUG
                System.Diagnostics.Trace.WriteLine(o);
#else
            Console.WriteLine(o);
#endif
            }

            public void Write(object o)
            {
#if DEBUG
                System.Diagnostics.Trace.Write(o);
#else
            Console.Write(o);
#endif
            }

            public CodeforcesUtils(string test_input)
            {
                _test_input = test_input;
            }

            string _test_input;

            List<string> _lines;
        }

        #endregion
    }
}