N queens are placed on a chessboard of size N × N. We'll say that these queens are in peaceful position if none of them can attack another. You are to find the total amount of peaceful positions that can be obtained from the given peaceful position by rearranging of exactly three queens.
Input
The first line contains an integer N (4 ≤ N ≤ 50). It is followed by N lines describing positions of queens. Each line contains integers X and Y representing horizontal and vertical coordinates (1 ≤ X, Y ≤ N).
Output
Output the number of peaceful positions that can be achieved from the initial position by moving of exactly three queens.
Note: the queens are not numbered so if you rearrange them on the chessboard using only squares they already occupied you’ll get the same peaceful position, not the new one.
Sample
input | output |
---|
4
2 1
1 3
3 4
4 2
| 0
|
Problem Author: Dmitry Filimonenkov
Problem Source: Ural Collegiate Programming Contest '99