Under construction

Still being built. Things may change

Pentagon

Time limit2sMemory limit1024 MB

Summary
Given up to 10,000 pentagons by their vertex coordinates, count the triangulations of each one, where every pentagon has 5 possible diagonal sets with at most 5 triangulations per shape.
Level

Easy3 of 10

Topics
Geometry, Dynamic programming
Solved
No attempts yet

Statement

You are given a pentagon. Find the number of its triangulations.

A triangulation of polygon PP is a collection of triangles such that the internal areas of these triangles have no common points, and their union is equal to PP. Each vertex of each triangle must coincide with some vertex of the polygon. Each side of each triangle must either fully coincide with some side of the polygon or have exactly two common points (endpoints) with the border of the polygon.

Input

The first line contains one integer nn, the number of test cases (1≤n≤10 0001 \le n \le 10\,000). Each test case is preceded by a single empty line.

Each test case describes one pentagon and consists of five lines. Each line contains two integers xx and yy separated by a single space: the coordinates of the next vertex of the pentagon, listed in clockwise or counter-clockwise order (−100≤x,y≤100-100 \le x, y \le 100). Every pentagon has no self-intersections and no self-touchings. No two adjacent sides of the polygon lie on the same line.

Output

Print nn lines, one for each test case. Each line contains one integer: the number of different triangulations of the corresponding pentagon.

Hint

The figure below shows all possible triangulations of the first pentagon in the example.

Examples1

  1. Example 1

    Input
    2
    
    -5 0
    0 3
    5 0
    2 -2
    -2 -2
    
    -5 -5
    -5 5
    5 5
    5 -5
    0 0
    
    Expected output
    5
    1