문제
Bessie has
Bessie draws some segments between the points as follows.
She chooses some permutation
p1,p2,…,pN of theN points.She draws segments between
p1 andp2 ,p2 andp3 , andp3 andp1 .Then for each integer
i from4 toN in order, she draws a line segment frompi topj for allj<i such that the segment does not intersect any previously drawn segments (aside from at endpoints).
Bessie notices that for each i, she drew exactly three new segments. Compute the number of permutations Bessie could have chosen on step 1 that would satisfy this property, modulo
.
입력
The first line contains
Followed by
출력
The number of permutations modulo
예제1
4
0 0
0 4
1 1
1 2
0
No permutations work.
예제2
4
0 0
0 4
4 0
1 1
24
All permutations work.
예제3
5
0 0
0 4
4 0
1 1
1 2
96
One permutation that satisfies the property is
First, she draws segments between every pair of
Then she draws segments from
Finally, she draws segments from
Diagram:

The permutation does not satisfy the property if its first four points are