Law 11: Offside Position

Given the ball's position and 11 attackers plus 11 defenders, decide whether any attacker is in an offside position per two coordinate conditions.

Easy3ImplementationGeometryBrute forceSortingInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

Of the seventeen laws of soccer, Law 11 on offside is probably the most argued about. Offside has two parts: the offside position, and the state of play that turns that position into an offense. To judge offside offenses consistently, and to quiet the parents who are sure they know the rules better than the referee but will not referee themselves, your team has been asked to write the analysis algorithm for Offside Enforcement Technology (OET). This phase covers the offside position only.

A player is in an offside position when both of the following hold.

  • Any part of the player's head, body, or feet is in the opponents' half. The halfway line itself does not count as the opponents' half. Hands and arms are ignored.
  • Any part of the player's head, body, or feet is closer to the opponents' goal line than the ball, and is also closer to the opponents' goal line than all but one of the eleven opponents.

Treat the ball and every player as a single point. The field is 100m long and 80m wide, the point (0,0)(0, 0) is the center of the halfway line, and the opponents' goal line runs from (50,40)(50, -40) to (50,40)(50, 40), so a larger xx is closer to that goal line. Decide whether at least one of the eleven attacking players is in an offside position.

Field coordinate system

Input

The input is a single test case of exactly 23 lines. Each line holds two integers xx and yy (50x50-50 \le x \le 50, 40y40-40 \le y \le 40), the position of the ball or of a player on the field in meters. The first line is the ball. The next 11 lines are the eleven attacking players, and the last 11 lines are the eleven defending players. No two players share a position.

Output

Print 1 if at least one attacking player is in an offside position, and 0 otherwise.