Honeycomb, Honeycomb, Me Want Honeycomb!

Time limit1sMemory limit128 MB

Problem

A windstorm has knocked over a beekeeper's hive boxes. A hive box holds several panels, and each panel holds one honeycomb. The panels are thin enough that the bees build only a single layer of hexagonal cells in each one, and every cell is a hexagon of the same size.

While inspecting the panels, the beekeeper finds that many hexagonal cells have been damaged. You are given a list of line segments representing the cell walls that are still intact. Count how many hexagons in the panel are undamaged, that is, how many still have all six of their walls.

The only kind of damage is that some cell walls are missing. No wall has been moved, broken in half, or otherwise altered.

Input

The first line contains a single integer $N$ ($1 \le N \le 100$), the number of data sets.

Each data set begins with a line containing a single integer $S$ ($1 \le S \le 1000$), the number of line segments in that data set. The next $S$ lines each describe one cell wall in the form X1,Y1 X2,Y2.

Every coordinate is a real number with $0 \le X, Y \le 1000$ and at most 3 digits after the decimal point (rounded to the nearest thousandth). Coordinates never use exponent notation such as 3.123e+3.

You may assume:

  • Each cell wall has length exactly 1.
  • The honeycomb is always oriented the same way: whenever a cell's top or bottom wall is present, that wall is parallel to the x-axis.
  • No two segments are duplicated or overlapping; segments may only touch one another at their endpoints.

Output

For each data set, print a single line containing the number of undamaged hexagonal cells (cells that still have all six walls).