See the Sights on the Flights

시간 제한3초메모리 제한1024 MB

요약
모든 지하철 노선이 한 점에서 만나고 각 경로가 모든 노선과 한 번씩 만날 때, 각 경로에서 가장 가까운 교차역까지의 거리를 구한다.
난이도

보통10점 중 7점

유형
기하, 수학, 이분 탐색
정답자
아직 제출이 없습니다

문제

Dima is an architect. He is also a photographer. He spends his time on travelling around the world and making photos of cool buildings like Big Ben etc.

This time Dima went to Berland famous with its subway system. It consists of nn lines, each of which is represented with a line on the map of the city. For any two lines there is a subway station in their intersection point, those station entrances are considered to be the notable pieces of architecture. Dima decided to take a photo of them.

In order to take the panoramic photo, he is going to use a helicopter flight. Helicopter may use one of the tt routes. Each route is also represented with a line on the map of the city. Dima is able to make a photo from an arbitrary point of the route, though the smaller distance from his location to the station means the better photo and the larger number of likes he is going to receive in social networks. That's why Dima needs your help.

You are given nn descriptions of the subway lines and tt lines defining the helicopter routes. For each of the helicopter routes Dima asks you to find the distance to the closest subway station.

It is guaranteed that no two subway lines coincide, any two subway lines have a common point, any two routes have a common point and each route has exactly one common point with each subway line.

입력

In the first line of the input there are two integers nn, tt (2≤n≤100,0002 \le n \le 100\\,000, 1≤t≤201 \le t \le 20) --- the number of subway lines and the number of helicopter routes, respectively.

In each of the following nn lines there are three integers a_ia\_i, b_ib\_i and c_ic\_i (∣a_i∣,∣b_i∣≤10,000|a\_i|, |b\_i| \le 10\\,000, a_i2+b_i2>0a\_i^2+b\_i^2>0, ∣c_i∣≤108|c\_i| \le 10^8) defining each of the subway lines. The corresponding line is defined by the equation a_i⋅x+b_i⋅y+c_i=0a\_i\cdot x + b\_i \cdot y + c\_i = 0.

In each of the following tt lines there are three integers u_iu\_i, v_iv\_i, w_iw\_i (∣u_i∣,∣v_i∣≤10,000|u\_i|, |v\_i| \le 10\\,000, u_i2+v_i2>0u\_i^2+v\_i^2 > 0, ∣w_i∣≤108|w\_i| \le 10^8) defining each of the helicopter routes. Similarly, each route is defined with the equation u_i⋅x+v_i⋅y+w_i=0u\_i \cdot x + v\_i \cdot y + w\_i = 0.

출력

For each route output the only real number --- the distance between ii-th helicopter route and its most closest subway station. Your answer will be considered correct if the absolute or relative error between your answer and the answer of the jury doesn't exceed 10−910^{-9}. Namely, ∣p−j∣max⁡(1,j)≤10−9\frac{|p-j|}{\max(1,j)} \leq 10^{-9} where pp is your answer and jj is the answer of the jury.

힌트

The pictures for the samples are provided below.

예제2

  1. 예제 1

    입력
    3 1
    1 -1 0
    1 1 -4
    4 -6 -4
    0 1 0
    
    예상 출력
    1.2
    
  2. 예제 2

    입력
    3 3
    1 3 -6
    -1 1 0
    -5 2 15
    3 -2 -3
    -1 -1 4
    1 0 -5
    
    예상 출력
    0.41602514717
    0.16637806616
    0.0