/*--------------------------------------------------------------*/
/* ACM ICPC 2009-2010, NEERC                                    */
/* Northern Subregional Contest                                 */
/* St Petersburg, October 17, 2009                              */
/*--------------------------------------------------------------*/
/* Problem F. Four Points                                       */
/*                                                              */
/* Original idea         Mikhail Dvorkin                        */
/* Problem statement     Yury Petrov                            */
/* Testset               Yury Petrov                            */
/*--------------------------------------------------------------*/
/* Checker                                                      */
/*                                                              */
/* Author                yp                                     */
/*--------------------------------------------------------------*/

#include "testlib.h"
#include <string>
#include <cmath>

using namespace std;

const double eps = 1.1e-6;

struct vec
{
  double x, y;
  vec( double xx = 0.0, double yy = 0.0 ) : x(xx), y(yy) {}
  vec operator - ( vec b ) { return vec(x - b.x, y - b.y); }
  vec operator * ( double b ) { return vec(x * b, y * b); }
  vec operator / ( double b ) { return vec(x / b, y / b); }
  double operator ^ ( vec b ) { return x * b.y - y * b.x; }
  vec ort() { return vec(-y, x); }
  bool operator == ( vec b )
    { return fabs(x - b.x) < eps && fabs(y - b.y) < eps; }
  bool operator != ( vec b )
    { return fabs(x - b.x) >= eps || fabs(y - b.y) >= eps; }
  double d2() { return x * x + y * y; }
  double d() { return sqrt(d2()); }
  vec norm() { return (d() > eps) ? *this / d() : *this; }
};

vec p[4], jp[5], pp[5];
bool jIs, pIs;
string checkRes;

bool isOn( vec a, vec b, vec c )
{
  if (a == b || a == c)
    return true;

    double a1 = (b - c).y;
    double b1 = (c - b).x;
    double c1 = a1 * b.x + b1 * b.y;
    double d = sqrt(a1 * a1 + b1 * b1);
    a1 /= d;
    b1 /= d;
    c1 /= d;

  return fabs(a1 * a.x + b1 * a.y - c1) < eps &&
    min(b.x, c.x) - eps < a.x && a.x < max(b.x, c.x) + eps &&
    min(b.y, c.y) - eps < a.y && a.y < max(b.y, c.y) + eps;
}

bool check( vec q[] )
{
  q[4] = q[0];
  vec d[2][4];
  d[0][0] = d[1][0] = q[1] - q[0];
  for (int i = 0; i < 3; i++)
    d[0][i + 1] = d[0][i].ort(), d[1][i + 1] = d[1][i].ort() * -1.0;
  bool isSq = false;
  for (int i = 0; i < 2; i++)
  {
    bool ok = true;
    for (int j = 0; j < 4; j++)
      if (!(q[j + 1] - q[j] == d[i][j]))
        ok = false;
    if (ok)
      isSq = true;
  }
  if (!isSq)
  {
    checkRes = "points do not form a square";
    return false;
  }
  int c1[4] = {0, 0, 0, 0}, c2[4] = {0, 0, 0, 0};
  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 4; j++)
      if (isOn(p[i], q[j], q[j + 1]))
        c1[i]++, c2[j]++;
  for (int i = 0; i < 4; i++)
    if (c1[i] < 1)
    {
      checkRes = "point is not on the border";
      return false;
    }
  for (int i = 0; i < 4; i++)
    if (c2[i] < 1)
    {
      checkRes = "number of points on a side is less than 1";
      return false;
    }
  return true;
}

int main( int argc, char *argv[] )
{
  setName("Checker for problem ``Four''");
  registerTestlibCmd(argc, argv);
  for (int i = 0; i < 4; i++)
  {
    p[i].x = inf.readReal();
    p[i].y = inf.readReal();
  }
  jIs = false;
  for (int i = 0; i < 4; i++)
  {
    jp[i].x = ans.readReal();
    jp[i].y = ans.readReal();
    if (jp[i].x != 0 || jp[i].y != 0)
      jIs = true;
  }
  if (jIs && !check(jp))
    quitf(_fail, "Jury answer is incorrect: %s", checkRes.c_str());
  pIs = false;
  for (int i = 0; i < 4; i++)
  {
    pp[i].x = ouf.readReal();
    pp[i].y = ouf.readReal();
    if (pp[i].x != 0 || pp[i].y != 0)
      pIs = true;
  }
  if (pIs && !check(pp))
    quitf(_wa, "Answer is incorrect: %s", checkRes.c_str());
  if (!jIs && pIs)
    quitf(_fail, "Jury found no solution while it exists");
  if (jIs && !pIs)
    quitf(_wa, "Solution was not found while it exists");
  quitf(_ok, "Ok, %s", jIs ? "Yes" : "No");
  return 0;
}

