#P1648. Maximum Manhattan Distance

    ID: 14934 Type: Default 1000ms 256MiB

Maximum Manhattan Distance

Maximum Manhattan Distance

You are given n points in a d-dimensional space. Your task is to find the maximum Manhattan distance between any two points.

The Manhattan distance between two points \((x_1,x_2,\ldots,x_d)\) and \((y_1,y_2,\ldots,y_d)\) is defined as:

[ |x_1-y_1| + |x_2-y_2| + \cdots + |x_d-y_d| ]

Compute and output the maximum Manhattan distance among all pairs of points.

inputFormat

The first line contains two integers n and d, where n is the number of points and d is the dimension of the space.

Each of the following n lines contains d integers representing the coordinates of a point.

You can assume that all input values are separated by spaces.

outputFormat

Output a single integer: the maximum Manhattan distance between any two points in the given set.

sample

2 2
0 0
1 1
2