atcoder#CADDI2018BB. AtCoder Alloy

AtCoder Alloy

Score : 200200 points

Problem Statement

There are NN rectangular plate materials made of special metal called AtCoder Alloy. The dimensions of the ii-th material are Ai×BiA_i \times B_i (AiA_i vertically and BiB_i horizontally).

Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are exactly H×WH \times W. He is trying to obtain such a plate by choosing one of the NN materials and cutting it if necessary. When cutting a material, the cuts must be parallel to one of the sides of the material. Also, the materials have fixed directions and cannot be rotated. For example, a 5×35 \times 3 material cannot be used as a 3×53 \times 5 plate.

Out of the NN materials, how many can produce an H×WH \times W plate if properly cut?

Constraints

  • 1N10001 \leq N \leq 1000
  • 1H1091 \leq H \leq 10^9
  • 1W1091 \leq W \leq 10^9
  • 1Ai1091 \leq A_i \leq 10^9
  • 1Bi1091 \leq B_i \leq 10^9

Input

Input is given from Standard Input in the following format:

NN HH WW

A1A_1 B1B_1

A2A_2 B2B_2

::

ANA_N BNB_N

Output

Print the answer.

3 5 2
10 3
5 2
2 5
2

Takahashi wants a 5×25 \times 2 plate.

  • The dimensions of the first material are 10×310 \times 3. We can obtain a 5×25 \times 2 plate by properly cutting it.
  • The dimensions of the second material are 5×25 \times 2. We can obtain a 5×25 \times 2 plate without cutting it.
  • The dimensions of the third material are 2×52 \times 5. We cannot obtain a 5×25 \times 2 plate, whatever cuts are made. Note that the material cannot be rotated and used as a 5×25 \times 2 plate.
10 587586158 185430194
894597290 708587790
680395892 306946994
590262034 785368612
922328576 106880540
847058850 326169610
936315062 193149191
702035777 223363392
11672949 146832978
779291680 334178158
615808191 701464268
8