Given n sequences, each containing m elements, choose exactly one element from each sequence such that the difference between the largest and smallest chosen elements is minimized.
- The first line contains two integers n and m.
- The next n lines each contain m integers, representing a sequence.
Output
- Print a single integer, the minimum possible difference between the largest and smallest chosen elements.
Constraints
- 1≤n,m≤1000.
- The absolute value of the numbers in the sequences does not exceed 109.
Example
Input:
3 4
12 16 67 43
7 17 68 48
14 15 77 54
Output:
2