This page is still under construction.

Parts of this page are still being built. What you see may change.

Fortress Wall

Time limit10sMemory limit512 MB

Summary
Count square one-cell-thick borders of size at least L that fit in an H by W grid without covering a tree.
Level

Medium7 of 10

Topics
Prefix sum, Matrix
Solved
No attempts yet

Problem

Professor JOI, a historian, studies the IOI Kingdom that existed long ago.

Earlier surveys say the IOI Kingdom was a grid HH cells tall and WW cells wide, and that its capital was ringed by a fortress wall for defense.

The wall around the capital had this shape.

  • A wall has a size ss with s≥3s \ge 3.
  • A wall of size ss is an s×ss \times s square region with its inner (s−2)×(s−2)(s-2) \times (s-2) square region removed, so it is a border one cell thick.

Another survey says the size of the wall around the capital was at least LL. Some cells hold an old tree, and a cell with a tree held no wall. The wall occupies the border only, so a tree strictly inside the border does not block it.

Professor JOI wants to know how many walls are possible given these facts. Two walls of the same size in different positions count as different walls.

Given the size of the kingdom, the minimum size of the wall, and the positions of the trees, write a program that counts the possible walls.

Input

The first line contains the integers HH, WW, LL, PP separated by spaces. The kingdom is HH cells tall and WW cells wide, the minimum size of the wall is LL, and the number of trees is PP.

Each of the next PP lines contains the position of a tree, AiA_i and BiB_i, separated by a space. The ii-th tree stands in row AiA_i from the top and column BiB_i from the left.

Output

Print the number of possible walls on the first line.

Constraints

  • 1≤H,W≤40001 \le H, W \le 4000
  • 3≤L≤min⁡(H,W)3 \le L \le \min(H, W)
  • 0≤P≤1000000 \le P \le 100000
  • 1≤Ai≤H1 \le A_i \le H (1≤i≤P1 \le i \le P)
  • 1≤Bi≤W1 \le B_i \le W (1≤i≤P1 \le i \le P)
  • (Ai,Bi)≠(Aj,Bj)(A_i, B_i) \ne (A_j, B_j) whenever i≠ji \ne j

Examples3

  1. Example 1

    Input
    5 5 3 2
    2 2
    4 3
    
    Expected output
    4
    
  2. Example 2

    Input
    7 8 4 3
    2 2
    3 7
    6 5
    
    Expected output
    13
    
  3. Example 3

    Input
    4000 4000 1234 4
    1161 3028
    596 1892
    3731 2606
    702 1530
    
    Expected output
    7050792912