8661: Photos

内存限制:128 MB 时间限制:3 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:1 通过:1

题目描述

You have a square farm, divided into n×n cells. There are mm beautiful cells among all cells, whose locations are given. You would like to take some photos of the farm. A photo should figure a square area of the farm, with vertices located on grid points and edges parallel to the grid lines. What's more, its principal diagonal should lie on the principal diagonal of the whole farm.

You would like to take several photos so that each beautiful cell is contained in one photo. You hate repetitions so that any two of your photos should not coincide, that is, their common area is 0. Each photo can contain an arbitrary number of beautiful cells, possibly 0011 or more. Count the number of set of photos satisfying the above conditions, modulo 998244353

In case you are confused, here we provide an illustration. The farm shown in this illustration is the same as the one in the sample test case.


输入格式

The first line of input contains a single integer T(1T1500), indicating the number of test cases. Then T test cases follow.

The first line of each test case contains two space-separated integers n,m(1n109,1m105), denoting the size of the farm and the number of good cells. Each of the next mm lines contains two space-separated integers xi,yi(1xi,yin), denoting the coordinates of a good cell.

It is guaranteed that m106.

输出格式

For each test case, print a line consisting of a single integer, indicating the answer modulo 998244353

输入样例 复制

1
6 2
4 2
3 4

输出样例 复制

24