Under construction

Still being built. Things may change

WiFi

Interview

Time limit1sMemory limit512 MB

Summary
Given the study room's public WiFi and each room's hotspot, compute the public signal speed in every room and print the maximum, or IMPOSSIBLE if none is positive.
Level

Easy3 of 10

Topics
Implementation, Math, Brute force, Geometry
Solved
No attempts yet

Problem

Wooseok does not want to leave his room even to go to the nearby small study room, so he wants to use WiFi from his room. The small study room has its own public WiFi, but students who were unhappy with its speed turned on hotspot WiFi, and those signals interfered with the study room's WiFi signal. Wooseok wants to estimate the speed of the public WiFi he can use despite the interference.

There are NN rooms, numbered 11 to NN, and the position of each room and of the small study room can be represented as a point on a 2D plane. Room ii is at (xi,yi)(x_i, y_i), and the small study room is at (x0,y0)(x_0, y_0).

The speed of the study room's WiFi reaching each room is computed as follows.

  • The small study room has a public WiFi turned on with energy E0E_0.
  • Each room ii has at most one hotspot WiFi turned on.
    • If Ei≠0E_i \neq 0, a hotspot WiFi with energy EiE_i is turned on; if Ei=0E_i = 0, no hotspot WiFi is turned on.
  • The strength of a WiFi signal decays from its energy by the taxicab distance between where the WiFi is turned on and where the WiFi is used, and it does not decay below 00.
    • That is, when a WiFi with energy PP turned on at (a,b)(a, b) reaches (c,d)(c, d), its strength is max⁡(0,P−(∣a−c∣+∣b−d∣))\max(0, P-(|a-c|+|b-d|)).
  • The WiFi speed reaching room ii is the strength of the public WiFi reaching room ii minus the sum of the strengths of all hotspot WiFi signals reaching room ii.
    • If the WiFi speed is 00 or less, WiFi cannot be connected in room ii.

Bold Wooseok can break into other rooms if it means getting WiFi. For Wooseok, find the public WiFi speed of the room with the fastest public WiFi.

Input

The first line gives the number of rooms NN.

Of the following N+1N+1 lines, the ii-th line gives xi−1x_{i-1}, yi−1y_{i-1}, Ei−1E_{i-1} separated by spaces.

Output

Print the speed in the room with the fastest public WiFi. If no room can connect to the public WiFi, print "IMPOSSIBLE" (without quotes).

Constraints

  • 1≤N≤1 0001 \le N \le 1\,000
  • 0≤xi,yi≤1 0000 \le x_i, y_i \le 1\,000 (0≤i≤N0 \le i \le N)
  • 0≤Ei≤1 0000 \le E_i \le 1\,000 (1≤i≤N1 \le i \le N)
  • 1≤E0≤1 000 0001 \le E_0 \le 1\,000\,000
  • All numbers in the input are integers.

Hint

Note that even in the same room, a hotspot WiFi that is turned on interferes with the public WiFi signal.

Examples2

  1. Example 1

    Input
    3
    0 1 7
    3 2 3
    0 3 3
    0 1 0
    
    Expected output
    6
    
  2. Example 2

    Input
    1
    1 4 15
    13 5 4
    
    Expected output
    IMPOSSIBLE