Universal Cup Judging System

Universal Cup

Límite de tiempo: 2.0 s Límite de memoria: 1024 MB Puntuación total: 100 Hackeable ✓
Estadísticas

Little Ika: Doo Doo Doo $\sim$.

Hyacinthia vuole raggiungere il centro di "Cloud End Ruins" Eye of Dawn per cercare un bottino, ma ci sono $n$ muri che le bloccano il cammino. L'$i$-esimo muro è un cerchio centrato nell'origine $(0, 0)$ con raggio $r_i$. Ci sono $k_i$ porte sul muro, e le coordinate della $j$-esima porta sono date da $\left(r_i \cdot \cos\left(\frac{2\pi}{M} \cdot p_{i,j}\right), r_i \cdot \sin\left(\frac{2\pi}{M} \cdot p_{i,j}\right)\right)$. Lo spessore del muro e la larghezza delle porte sono trascurabili, e Hyacinthia non può volare sopra i muri.

Hyacinthia vuole farti $m$ domande. Ogni volta ti dirà il suo punto di partenza e tu dovrai rispondere qual è la distanza minima dal centro. È garantito che il punto di partenza si trovi sul lato interno di un muro e proprio accanto alla superficie del muro.

Input

La prima riga contiene due interi $n, m$ ($2 \le n \le 2 \cdot 10^5, 1 \le m \le 2 \cdot 10^5$), che rappresentano il numero di muri e il numero di query.

Le successive $n$ righe descrivono ciascun muro. Ogni riga inizia con due interi $r_i, k_i$ ($1 \le r_i \le 10^8, 0 \le k_i \le 2 \cdot 10^5$), ad indicare che l'$i$-esimo muro è un cerchio di raggio $r_i$ e ha $k_i$ porte. Seguono $k_i$ interi $p_{i,1}, p_{i,2}, \dots, p_{i,k_i}$, ad indicare che le coordinate della $j$-esima porta sono $\left(r_i \cdot \cos\left(\frac{2\pi}{M} \cdot p_{i,j}\right), r_i \cdot \sin\left(\frac{2\pi}{M} \cdot p_{i,j}\right)\right)$, dove $M = 3.6 \cdot 10^8$. È garantito che $0 \le p_{i,1} < p_{i,2} < \dots < p_{i,k_i} < M$, $k_n = 0$, $\sum_{i=1}^n k_i \le 2 \cdot 10^5$, e $1 \le r_1 < r_2 < \dots < r_n \le 10^8$.

Le successive $m$ righe contengono ciascuna due interi $t_i, q_i$, che chiedono qual è la distanza minima dall'origine se Hyacinthia parte dall'interno del $t_i$-esimo muro nel punto $\left(r_{t_i} \cdot \cos\left(\frac{2\pi}{M} \cdot q_i\right), r_{t_i} \cdot \sin\left(\frac{2\pi}{M} \cdot q_i\right)\right)$ (se non è raggiungibile, stampa "-1").

Output

Per ogni query, stampa una singola riga con un numero in virgola mobile che rappresenta la risposta. Se non è raggiungibile, stampa "-1". Una risposta è considerata corretta se l'errore relativo o assoluto non supera $10^{-6}$ rispetto alla risposta standard.

Esempi

Input 1

3 4
2 2 0 90000000
5 0
8 0
1 114514
2 0
2 180000000
3 233

Output 1

2.0000000000
5.0000000000
7.4056093871
-1

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.