Criminals

아직 제출이 없습니다시간 제한4초메모리 제한512 MB

문제

In an ancient country, there are n×mn \times m cities, labeled by integers from 11 to nmn \cdot m. The coordinates of the city labeled by (x1)m+y(x - 1) \cdot m + y are (x,y)(x, y) (1xn1 \leq x \leq n, 1ym1 \leq y \leq m). There are qq tourists. Initially, the ii-th tourist is at city (x_i,y_ix\_i, y\_i). All tourists want to go out and play in other cities.

Unfortunately, KK of the nmn \cdot m cities are controlled by  criminals, so these KK cities are unsafe. For safety reasons, a tourist whose initial coordinates are (x_1,y_1)(x\_1, y\_1) can go to the city (x_2,y_2)(x\_2, y\_2) if and only if all of the cities (x,y)(x, y) (min(x_1,x_2)xmax(x_1,x_2)\min (x\_1, x\_2) \leq x \leq \max (x\_1, x\_2), min(y_1,y_2)ymax(y_1,y_2)\min (y\_1, y\_2) \leq y \leq \max (y\_1, y\_2)) are safe.

Now, for each tourist, calculate the number of cities they can reach safely (including their initial city).

입력

The first line of the input contains four integers nn, mm, KK and qq (1n,m,K,q1051 \leq n, m, K, q \leq 10^5).

Then KK lines follow. Each of these lines contains two integers a_ia\_i and b_ib\_i: the coordinates of an unsafe city (1a_in1 \leq a\_i \leq n, 1b_im1 \leq b\_i \leq m). It is guaranteed that each city appears at most once in this list.

Then qq lines follow. Each of these lines contains two integers x_ix\_i and y_iy\_i: the initial city of each tourist (1x_in1 \leq x\_i \leq n, 1y_im1 \leq y\_i \leq m). It is guaranteed that, initially, each tourist stays at a safe city.

출력

For each tourist, print a single line with a single integer: the number of cities this tourist can reach safely.

힌트

In the example, the third tourist can reach eight cities: (1,4)(1, 4), (2,4)(2, 4), (3,4)(3, 4), (4,4)(4, 4), (1,3)(1, 3), (2,3)(2, 3), (2,2)(2, 2) and (2,1)(2, 1).