Cruel Bingo#3550

Cruel Bingo

8 seconds
32 megabytes
Very hard

Bingo is a party game played by many players and one game master. Each player is given a bingo card containing N^2 different numbers in a N \times N grid (typically N = 5). The master draws numbers from a lottery one by one during the game. Each time a number is drawn, a player marks a square with that number if it exists. The player's goal is to have marked squares in a single vertical, horizontal, or diagonal line and then call "Bingo!" The first player calling "Bingo!" wins the game.

In ultimately unfortunate cases, a card can have exactly unmarked squares, or N(N-1) marked squares, but not a bingo pattern. Your task in this problem is to write a program counting how many such patterns are possible from a given initial pattern, which contains zero or more marked squares.

Input

The input is given in the following format:

x_1 y_1 ... x_K y_K

The input begins with a line containing two numbers (1 \le N \le 32) and (0 \le K \le 8), which represent the size of the bingo card and the number of marked squares in the initial pattern respectively. Then lines follow, each containing two numbers x_i and y_i to indicate the square at (x_i, y_i) is marked. The coordinate values are zero-based (i.e. 0 \le x_i, y_i \le N-1). No pair of marked squares coincides.

Output

Count the number of possible non-bingo patterns with exactly unmarked squares that can be made from the given initial pattern, and print the number in modulo in a line (since it is supposed to be huge). Rotated and mirrored patterns should be regarded as different and counted each.

Examples

Example 1

Loading
Loading