QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 256 MB 満点: 100

#7817. Virology

統計

A virologist conducted experiments on $K$ strains of a virus and recorded the temperatures at which each strain dies. The number of experiments for each strain may vary. We define the size of a temperature range that kills all virus strains as the difference between the boundaries of a range that contains at least one temperature for the destruction of each virus strain. Help the virologist determine the minimum possible size of such a range.

Input

The first line contains a single positive integer $K$ — the number of virus strains, $1 \leqslant K \leqslant 10^5$. Following this are $K$ lines, each containing space-separated integers. In the $i$-th line, the first number $M_i$ is the number of experiments on the $i$-th strain that resulted in the destruction of the strain, $1 \leqslant M_i \leqslant 10^5$, followed by $M_i$ temperature values from the experiments in which the strain died, with all values in the range from $-10^7$ to $10^7$. The total number of experiments conducted across all virus strains does not exceed $10^5$.

Output

A single integer — the minimum possible size of the temperature range that is lethal for all virus strains.

Examples

Input 1

3
5 3 9 15 24 20
4 1 9 13 14
4 5 15 12 11

Output 1

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.