2761. The Computer Game

单点时限: 5.0 sec

内存限制: 256 MB

John and Brus are playing a military strategic game on a PC. The game is played on the flat world map. At the beginning of the game Brus places his army. Then John has to choose strategic points for his army according to the following rules:

  • each strategic point must be a lattice point $(x, y)$ (a lattice point is a point with integer coordinates) such that $|x| + |y| < N$;
  • John can choose any positive number of strategic points;
  • all the strategic points must be distinct;
  • each of the strategic points must be free (i.e. not occupied by Brus’s army);
  • each pair of different strategic points must be connected (possibly via some other strategic points).

Here two different lattice points $(x_1, y_1)$ and $(x_2, y_2)$ are connected if $|x_1 – x_2| + |y_1 – y_2| = 1$. If $A$, $B$ and $C$ are strategic points, $A$ and $B$ are connected, $B$ and $C$ are connected, then $A$ and $C$ are also connected.

Your task is to find the number of ways for John to choose strategic points for his army.

输入格式

The first line contains single integer $T$ – the number of test cases.

Each test case starts with a line containing two integers $N$ and $M$ separated by a single space. $N$ is the number mentioned in the first rule. $M$ is the number of lattice points on the world map already occupied by Brus’s army. Each of the following $M$ lines contains two integers $X_k$ and $Y_k$ separated by a single space. Each lattice point $(X_k, Y_k)$ is occupied by Brus’s army.

Constraints:

  • $1 \le T \le 74$,
  • $1 \le N \le 7$,
  • $1 \le M \le 225$,
  • $-7 \le X_k, Y_k \le 7$,
  • all $(X_k, Y_k)$ will be distinct.

输出格式

For each test case print a single line containing the number of ways for John to choose strategic points for his army.

样例

Input
2
2 1
7 7
2 3
0 0
4 -7
7 -4
Output
20
4

0 人解决,3 人已尝试。

0 份提交通过,共有 4 份提交。

9.9 EMB 奖励。

创建: 15 年前.

修改: 7 年,1 月前.

最后提交: 1 年,4 月前.

来源: Southeastern European Regional Programming Contest 2009

题目标签