##### IOI '07 - Zagreb, Croatia

Mirko and Slavko are playing with toy animals. First, they choose one of three boards given in the figure below. Each board consists of cells (shown as circles in the figure) arranged into a one, two or three dimensional grid.

Board 1 |
Board 2 |
Board 3 |

Mirko then places little **toy animals** into the cells.

The **distance** between two cells is the smallest number of moves that an animal would need in order to reach
one cell from the other. In one move, the animal may step into one of the adjacent cells (connected by line
segments in the figure).

Two animals can hear each other if the distance between their cells is **at most** . Slavko's task is to calculate
how many **pairs of animals** there are such that one animal can hear the other.

Write a program that, given the board type, the locations of all animals, and the number , finds the desired number of pairs.

#### Input Specification

The first line of input contains four integers in this order:

- The board type ;
- The number of animals ;
- The largest distance at which two animals can hear each other ;
- The size of the board (the largest coordinate allowed to appear in the input):
- When , will be at most .
- When , will be at most .
- When , will be at most .

Each of the following lines contains integers separated by single spaces, the coordinates of one toy animal. Each coordinate will be between and (inclusive).

More than one animal may occupy the same cell.

#### Output

Output should consist of a single integer, the number of pairs of animals that can hear each other.

**Note:** use a 64-bit integer type to calculate and output the result (`long long`

in C/C++, `int64`

in Pascal).

#### Grading

In test cases worth a total of points, the number of animals will be at most .

Furthermore, for each of the three board types, a solution that correctly solves all test cases of that type will be awarded at least points.

#### Sample Input 1

```
1 6 5 100
25
50
50
10
20
23
```

#### Sample Output 1

`4`

#### Explanation for Sample Output 1

Suppose the animals are numbered through in the order in which they are given. The four pairs are:

- (distance )
- (distance )
- (distance )
- (distance )

#### Sample Input 2

```
2 5 4 10
5 2
7 2
8 4
6 5
4 4
```

#### Sample Output 2

`8`

#### Explanation for Sample Output 2

The eight pairs are:

- (distance )
- (distance )
- (distance )
- (distance )
- (distance )
- (distance )
- (distance )
- (distance )

## Comments