#P7529. [USACO21OPEN] Permutation G

[USACO21OPEN] Permutation G

Description

Bessie has NN favorite distinct points on the 2D plane, and no three points are collinear. For each 1iN1 \le i \le N, the ii-th point is given by two integers xix_i and yiy_i.

Bessie draws some line segments among these points in the following way:

    1. She chooses a permutation p1,p2,,pNp_1, p_2, \dots, p_N of the NN points.
    1. She draws line segments between p1p_1 and p2p_2, between p2p_2 and p3p_3, and between p3p_3 and p1p_1.
    1. Then, for each integer ii from 44 to NN in order, and for every j<ij < i, she draws a line segment from pip_i to pjp_j as long as this segment does not intersect any previously drawn segment (intersection at endpoints is allowed).

Bessie notices that for every ii, she draws exactly three new line segments. Compute the number of permutations she can choose in Step 1 that satisfy the property above, modulo 109+710^9 + 7.

Input Format

The first line contains NN.

The next NN lines each contain two space-separated integers xix_i and yiy_i.

Output Format

Output one integer: the number of valid permutations modulo 109+710^9 + 7.

4
0 0
0 4
1 1
1 2
0
4
0 0
0 4
4 0
1 1
24
5
0 0
0 4
4 0
1 1
1 2
96

Hint

Explanation for Sample 1

No permutation satisfies the property.

Explanation for Sample 2

All permutations satisfy the property.

Explanation for Sample 3

One valid permutation is (0,0),(0,4),(4,0),(1,2),(1,1)(0,0), (0,4), (4,0), (1,2), (1,1). For this permutation,

  • First, she draws line segments between each pair among (0,0)(0,0), (0,4)(0,4), and (4,0)(4,0).
  • Then she draws segments from (1,2)(1,2) to (0,0)(0,0), (0,4)(0,4), and (4,0)(4,0).
  • Finally, she draws segments from (1,1)(1,1) to (1,2)(1,2), (4,0)(4,0), and (0,0)(0,0).

Constraints

3N403 \le N \le 40, 0xi,yi1040 \le x_i, y_i \le 10^4.

Translated by ChatGPT 5