Time Limit : sec, Memory Limit : KB
English / Japanese  

Strawberry 2

Problem Statement

Hitaro, who loves fruit, decided to try picking strawberries. In front of Hitaro is a table with 1 leg. The table is rectangular and is divided into a grid of H rows and W columns. There are N strawberries on the table, and the i-th strawberry (1 ≦ i ≦ N) is located in the cell at row Ai from the top and column Bi from the left. Multiple strawberries may be placed in the same cell.

Hitaro selects 9 cells that form a square region of 3 rows and 3 columns, and takes all the strawberries in those cells. This action is performed exactly 1 time.

Hitaro wants to take as many strawberries as possible.

Given the size of the table and the positions of the strawberries, write a program to find the maximum number of strawberries that can be taken.

Constraints

  • 3 ≦ H ≦ 1 000 000 000.
  • 3 ≦ W ≦ 1 000 000 000.
  • 1 ≦ N ≦ 60 000.
  • 1 ≦ Ai ≦ H (1 ≦ i ≦ N).
  • 1 ≦ Bi ≦ W (1 ≦ i ≦ N).
  • All input values are integers.

Input

The input is given from standard input in the following format.
H W
N
A1 B1
A2 B2
:
AN BN

Output

Output the maximum number of strawberries that can be taken in 1 line to standard output.

Sample Input and Output

Sample Input 1

4 5
7
1 1
1 5
2 2
2 4
3 3
4 2
4 4

Sample Output 1

5

The arrangement of strawberries is shown in the figure (red circles represent strawberries).

Diagram of strawberry arrangement

By selecting the cells forming the region enclosed by the thick border, 5 strawberries can be taken.

Since it is not possible to take more than 5 strawberries, output 5.

Sample Input 2

3 5
6
1 1
1 2
2 1
2 4
2 4
3 4

Sample Output 2

4

Multiple strawberries may be placed in the same cell.

Sample Input 3

3 99999
9
1 77813
2 77813
3 77813
1 77814
2 77814
3 77814
1 77815
2 77815
3 77815

Sample Output 3

9

Sample Input 4

11 11
20
7 7
6 11
5 7
8 8
9 9
5 5
8 4
4 4
4 8
2 6
1 6
6 2
3 3
9 3
7 5
6 1
10 6
6 10
11 6
3 9

Sample Output 4

4

Creative Commons License

Japan Information Olympiad Committee "Japan Information Olympiad 2nd Women's Division Finals Problem"