Beehive Epidemic

No attempts yetTime limit2sMemory limit256 MB

Problem

The bee flu is running through the hives. To keep the colony alive, the bees of Inner Dreaded Illnessia keep a few cells of the hive free as safe zones. A bee that gets into a safe zone before the bacteria do survives the outbreak. The honey needs room too, so there are far fewer safe zones than bees and the bees have to share them out. Work out how many of them can be saved.

The hive is a hexagonal grid. Every cell has a coordinate (x,y)(x, y), and cell (x,y)(x, y) touches the six cells (x+1,y)(x+1, y), (x1,y)(x-1, y), (x,y+1)(x, y+1), (x,y1)(x, y-1), (x+1,y1)(x+1, y-1) and (x1,y+1)(x-1, y+1). The picture shows how the coordinates run. The hive is so large that no bee ever reaches its border.

  • Once every second a bee moves to a neighbouring cell or stays where it is. It reaches a cell at hex distance mm after mm seconds.
  • The bacteria hold their starting cells from the beginning and spread once every two seconds. The first spread happens right after second 2, the second one right after second 4, and so on. After the kk-th spread the bacteria hold every cell within hex distance kk of a starting cell.
  • Safe zones never move. A bee is saved when it enters a safe zone the bacteria have not reached yet and stays there. The bees make two moves before the first spread, so a bee that arrives at second 2k2k in a zone the bacteria reach with their kk-th spread is still in time.
  • A bee that stands in a safe zone at second 0 is not saved yet, because it is not hiding just in case. Its earliest safe moment is second 1, after one move, and staying in place counts as a move.
  • Only one bee is saved in each safe zone. Anywhere else the bees ignore each other, and any number of them may sit in the same cell while they travel.
  • Only the arrival at a safe zone counts. A travelling bee is never blocked or infected on the way.

Input

The first line contains the number of test cases TT. Each test case consists of four lines. The first line holds NN, SS and BB: the number of bees, of safe zones and of bacteria colonies. The second line holds x1 y1 x2 y2  xN yNx_1\ y_1\ x_2\ y_2\ \dots\ x_N\ y_N, the cells where the bees start. The third line holds the SS safe zones in the same format, and the fourth line the BB cells where the bacteria start.

  • 0<T1500 < T \le 150
  • 0<N,S500 < N, S \le 50
  • 0<B15000 < B \le 1500
  • 100xi,yi100-100 \le x_i, y_i \le 100
  • No two safe zones share a cell. Any other cell may repeat: several bees may start together, several bacteria colonies may share a cell, and a bee may start in a safe zone or on a bacteria cell.

Output

For each test case, print one line with the largest number of bees that can be saved.