Border Wall

Given two colored point sets and a width d, find the minimum number of points to delete so that a strip of width d separates the remaining points by color.

Hard8GeometrySortingBrute forceImplementationNo attempts yetTime limit2sMemory limit512 MB

Problem

Trunk, the new president of Demoland, promised during his campaign to build a wall along the border with the neighboring country Indoland. The wall follows one straight line. The trouble is that the houses of the two nations are mixed together, so no straight line splits them cleanly. Wherever the wall goes, some houses must be evacuated and their residents moved to the other side. The wall also has a width, so every house that overlaps it must be destroyed. Evacuating or destroying a house costs money, and a large number of such houses brings loud protest. The president wants to know the smallest number of houses that must be evacuated or destroyed for a wall of the width he wants.

The houses of each nation are given as a set of points in the plane, together with the wall width dd. The wall is the region between two parallel lines at distance dd. After some houses are removed, the wall separates the two remaining sets when both conditions below hold.

  1. No two houses of different nations lie on the same side of the wall.
  2. No house lies inside the wall. A house on either boundary line is allowed.

If d=0d = 0, the two boundary lines coincide, the wall is a single line, and a house on that line lies on neither side. Removing every house of one nation is allowed. Compute the minimum number of points that must be removed so that a wall of width dd separates the rest.

Input

The input holds several test cases. The first line of each test case has three integers nn, kk, dd, where nn is the number of houses owned by citizens of Demoland, kk is the number owned by citizens of Indoland, and dd is the width of the wall (1n,k1001 \le n, k \le 100, 0d<10000 \le d < 1000). Each of the next nn lines has two integers xx and yy (0x,y100000 \le x, y \le 10000), the position (x,y)(x, y) of a house owned by a citizen of Demoland. The next kk lines give the positions of the houses owned by citizens of Indoland in the same format. No two houses share a position. The input ends with a line holding 0 0 0, which is not processed.

Output

For each test case, print one line with the minimum number of houses that must be removed to build the wall. In an optimal solution every house of one nation may be removed.