Helen is hiking with her friends in a highland. The plan is to walk from their camp A to a lookout B.
Helen has started to feel dizzy from altitude sickness. Help the group find a route whose highest point is as low as possible.
The landscape is given as a set of triangles. A route is a polyline from A to B in which every segment lies entirely inside one of those triangles, so the route never leaves the surface. The topmost height of a route is the largest z coordinate of any point on it. Find the smallest topmost height over all routes from A to B.
The landscape covers a square region of size 106×106.
The first line contains one integer n, the number of triangles in the landscape (2≤n≤2000).
Each of the next n lines contains nine integers xi1, yi1, zi1, xi2, yi2, zi2, xi3, yi3, zi3, the coordinates of one triangle. Every coordinate belongs to the closed interval [0,106].
The last two lines contain three integers each: xA, yA, zA and xB, yB, zB, the coordinates of camp A and lookout B.
The triangles describe one consistent continuous landscape. Their projections onto the XY plane are non-degenerate and fill the square without overlapping. A vertex of one triangle never lies inside an edge of another triangle. A and B lie on the landscape surface and are different points.
Print one integer, the smallest topmost height that a route from A to B can have.