CF2178I Numbers or Fireworks

Description

Now that all the presents have been delivered, the North Pole is finally at peace — and it's time to celebrate with a spectacular New Year's fireworks show! The North Pole is modeled as the Cartesian plane, with $ n $ cities located at distinct lattice points. You are also given an integer $ k $ . For a proper subset $ ^{\text{∗}} $ $ T $ of the cities ( $ T $ may be empty), we define its explosiveness as follows: 1. A firework is launched from every city in $ T $ . 2. For each city $ c $ not in $ T $ , let $ f $ be the number of fireworks launched from cities that are exactly $ \sqrt{k} $ Euclidean distance $ ^{\text{†}} $ away from $ c $ . Assign the number $ (f+1) $ to this city $ c $ . 3. The explosiveness of $ T $ is the product of all numbers assigned in Step 2. Compute the sum of the explosiveness of $ T $ over all $ 2^n-1 $ proper subsets $ T $ of the cities. Since the answer may be large, output it modulo $ 998\,244\,353 $ . $ ^{\text{∗}} $ A proper subset is any subset which is not equal to the whole set. $ ^{\text{†}} $ The Euclidean distance between two points $ (x, y) $ and $ (p, q) $ is defined as $ \sqrt{(x - p)^2 + (y - q)^2} $ .

Input Format

Each test contains multiple test cases. The first line contains the number of test cases $ t $ ( $ 1 \le t \le 1000 $ ). The description of the test cases follows. The first line of each test case contains two integers $ n $ and $ k $ ( $ 2\le n\le 31 $ , $ 1\leq k \leq2\cdot 10^4 $ ). Then $ n $ lines follow, the $ i $ -th line containing two integers $ x_i $ and $ y_i $ ( $ 1\leq x_i, y_i\leq 100 $ ) — the $ x $ and $ y $ coordinates of the $ i $ -th city, respectively. It is guaranteed that the coordinates of the cities are pairwise distinct. It is guaranteed that the sum of $ n^3 $ over all test cases does not exceed $ 31^3 $ .

Output Format

For each test case, print a single integer — the sum, modulo $ 998\,244\,353 $ , of the explosiveness over all proper subsets $ T $ of the cities.

Explanation/Hint

In the first test case, below are the $ 2^3-1=7 $ possible placements of fireworks. The numbers assigned to cities not in $ T $ are circled. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF2178I/3ee0088ecb4ba17df9ec0e79ddc2389810b7d62705ff7a4820dee748715f415c.png)![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF2178I/b7f64eb03d8c313c412e7df3d1943f57a1811ddc7bd7c1e279c6236474b4fb74.png)![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF2178I/8a17c12b61c5138fd807a9b254bafa141fb94fce700f836a286cab122e652fcb.png)![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF2178I/4390bae1426ce3d755f825cacb93b9dbfcfad3fcc0fc1dff06d1f4882a75f0d6.png)![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF2178I/34a5539c4c486c8852fcf371f7d753230f71c420b015762f81a8b1331e97b8ff.png)![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF2178I/dffc6fce4c753611e8f173e3fdca64795bcb7eebcc00c711280753841a97a9bc.png)![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF2178I/1abe8539e8e3d01b16a9356d5d447af6e49c4638e2946ac13b193d8f4bdc5bdb.png) The total explosiveness is $ (1\cdot 1\cdot 1)+(1\cdot 2)+(2\cdot 1)+(2\cdot 2)+(3)+(2)+(2)=16 $ .In the second test case, there are $ 2^2-1=3 $ possible placements of fireworks. For every placement, since $ (1,1) $ and $ (100,100) $ have a Euclidean distance of $ \sqrt{(100-1)^2+(100-1)^2}=\sqrt{19\,602}\neq\sqrt{20\,000} $ , none of the cities will have fireworks that are exactly $ \sqrt{k} $ away. Thus, the number $ 1 $ is assigned to every city without fireworks. Therefore, the explosiveness is $ 1 $ for every $ T $ , and the answer is $ 1+1+1=3 $ .