Package for this problem was not updated by the problem writer or Codeforces administration after we’ve upgraded the judging servers. To adjust the time limit constraint, solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then value 800 ms will be displayed and used to determine the verdict.

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

C. Spiral Maximum

time limit per test

3 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputLet's consider a *k* × *k* square, divided into unit squares. Please note that *k* ≥ 3 and is odd. We'll paint squares starting from the upper left square in the following order: first we move to the right, then down, then to the left, then up, then to the right again and so on. We finish moving in some direction in one of two cases: either we've reached the square's border or the square following after the next square is already painted. We finish painting at the moment when we cannot move in any direction and paint a square. The figure that consists of the painted squares is a spiral.

You have an *n* × *m* table, each of its cells contains a number. Let's consider all possible spirals, formed by the table cells. It means that we consider all spirals of any size that don't go beyond the borders of the table. Let's find the sum of the numbers of the cells that form the spiral. You have to find the maximum of those values among all spirals.

Input

The first line contains two integers *n* and *m* (3 ≤ *n*, *m* ≤ 500) — the sizes of the table.

Each of the next *n* lines contains *m* space-separated integers: the *j*-th number in the *i*-th line *a*_{ij} ( - 1000 ≤ *a*_{ij} ≤ 1000) is the number recorded in the *j*-th cell of the *i*-th row of the table.

Output

Print a single number — the maximum sum of numbers among all spirals.

Examples

Input

6 5

0 0 0 0 0

1 1 1 1 1

0 0 0 0 1

1 1 1 0 1

1 0 0 0 1

1 1 1 1 1

Output

17

Input

3 3

1 1 1

1 0 0

1 1 1

Output

6

Input

6 6

-3 2 0 1 5 -1

4 -1 2 -3 0 1

-5 1 2 4 1 -2

0 -2 1 3 -1 2

3 1 4 -3 -2 0

-1 2 -1 3 1 2

Output

13

Note

In the first sample the spiral with maximum sum will cover all 1's of the table.

In the second sample the spiral may cover only six 1's.

Codeforces (c) Copyright 2010-2017 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jan/20/2018 16:13:37 (d3).

Desktop version, switch to mobile version.

User lists

Name |
---|