import random
from fractions import Fraction
from decimal import Decimal
import sys

class point:
    def __init__(self, x=0, y=0):
        self.x = x
        self.y = y
    def __add__(p, q): return point(p.x+q.x, p.y+q.y)
    def __sub__(p, q): return point(p.x-q.x, p.y-q.y)
    def __mul__(p, c): return point(c*p.x, c*p.y)
    def dot(p, q): return p.x*q.x + p.y*q.y
    def cross(p, q): return p.x*q.y - p.y*q.x
    def quadrant(self):
        if self.y > 0 and self.x >= 0: return 0
        if self.x < 0 and self.y >= 0: return 1
        if self.y < 0 and self.x <= 0: return 2
        return 3
    def __lt__(p, q):
        a = p.quadrant()
        b = q.quadrant()
        if a != b: return a < b
        return p.cross(q) > 0
    def __str__(self): return '(%s,%s)' % (self.x, self.y)
    
class ray:
    def __init__(self, P=None, dP=None):
        self.P = P if P else point()
        self.dP = dP if dP else point()
    def isect_exact(L1, L2):
        det = L1.dP.cross(L2.dP)
        if det == 0: return None
        s = Fraction(L2.dP.cross(L1.P-L2.P))/det
        return L1.P + L1.dP*s
    def isect_float(L1, L2):
        det = L1.dP.cross(L2.dP)
        if det == 0: return None
        s = 1.0*L2.dP.cross(L1.P-L2.P)/det
        return L1.P + L1.dP*s
    def __lt__(L1, L2): return L1.dP < L2.dP
    def __str__(self): return '%s dir %s' % (self.P, self.dP)
    
def area(P):
    return sum(P[i-1].P.cross(P[i].P) for i in range(len(P))) / 2


MAX_COORD = 10**6


def rand_point():
    return point(random.randint(0, 10**6), random.randint(0, 10**6))

def rand_line():
    P1 = rand_point()
    P2 = rand_point()
    return ray(P1, P2-P1)

best_err = 0.0

while True:
    L1 = rand_line()
    L2 = rand_line()

    q1 = L1.isect_exact(L2)
    if q1 is None: continue
    if not MAX_COORD/2 <= q1.x <= MAX_COORD: continue
    if not MAX_COORD/2 <= q1.y <= MAX_COORD: continue
    q2 = L1.isect_float(L2)

    e = q1-q2
    err = e.dot(e)
    if err > best_err:
        best_err = err
        print best_err, L1, L2
