Janggi Horse

No attempts yetTime limit1sMemory limit128 MB

Problem

Janggi is a board game with as long a tradition in Korea as Go. Players use several kinds of pieces to trap the opponent's general, and the basic strategy is to plan your own pieces a few moves ahead. Among those pieces the horse (馬) moves nimbly, so it comes up often. Its move is unusual, though, and beginners have trouble with it. Using the horse well starts with seeing the fewest moves it needs to get from where it stands to where you want it.

The horse moves as shown below. One move traces the character 日. This is close to the knight in chess, but the horse goes one square straight and then one square diagonally, so it cannot pass over a square that holds another piece.


Figure 1: how the horse moves
In one move the horse steps one square forward and then one square diagonally, tracing the character 日 overall.
The red circles are the squares the horse can reach in one move, when no piece sits in between.

Given a horse and other pieces on the board, write a program that computes the fewest moves the horse needs to reach its destination. Assume the board is infinitely wide. You are given the horse's current coordinates, the destination coordinates, and the coordinates of the other pieces. The other pieces stay where they are while the horse moves, and this infinite board has no palace (the area with diagonal move lines drawn across it). Assume the horse is never blocked so completely that it cannot reach the destination.

Input

Input comes from standard input. The first line contains the number of test cases TT (1T201 \le T \le 20).

For each test case, the first line holds the horse's current coordinates and the second line holds the coordinates the horse has to reach. The third line holds the number of other pieces KK (0K100000 \le K \le 10000), and each of the next KK lines holds the coordinates of one other piece. Those are the squares the horse cannot stand on. Every coordinate is two integers between 10000-10000 and 1000010000, separated by whitespace.

Output

Output goes to standard output. For each test case, print the fewest moves the horse needs, one per line.