Matrix Again
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 128 M,其他语言256 M
64bit IO Format: %lld

题目描述

KK is the engineer responsible for sensor sensing in MINIEYE. KK recently need to use radar to sense the vehicles ahead, and KK thought about it day and night, and finally found a perfect solution.

You are now an intern at KK. To give you an understanding of the principles of radar sensing, KK gives you a simplified version of this problem.

Given a matrix of N×M, each element is an integer. If there is a submatrix of L × L, and the difference between the maximum and the minimum of this submatrix is less than or equal to G, then this submatrix is considered as a car matrix. Now you need to find the largest L.

输入描述:

The first line contains three integers N, M, G(0 < N, M ≤ 500, 0 ≤ G ≤ 200).

Each of the following N lines contains M integers, representing the matrix. It is guaranteed that every integer in the matrix is in the range [-100, 100].

输出描述:

Output the maximum L in a single line.
示例1

输入

复制
3 3 4
0 1 2
3 4 5
6 7 8

输出

复制
2