Sponge
InterviewTime limit1sMemory limit1024 MB
Given K labeled viruses on a W by H grid that each move one king step or stay each second, count the distinct placements possible after T seconds modulo 998244353.
- Level
Easy3 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
The sponge is a grid with cells across and cells down. It is divided into cells, and holes in various places let viruses move through it.
Every second, a virus can move to one of the 8 neighboring cells (up, down, left, right, or diagonally) without leaving the sponge, or it can stay in its current cell. Several viruses can occupy the same cell. Their shapes differ, so they can be told apart.

raa was watching the viruses and wondered how many distinct virus distributions are possible after seconds. Two distributions differ if the position of any virus differs. Help raa count them.
Input
The first line contains the width , the height , the number of viruses , and the time that raa observes the viruses, separated by spaces. (, )
The next lines give the current positions of the viruses. Line contains two integers and , separated by a space. This means virus is in the cell that is cells from the left and cells from the top of the sponge. (, )
All numbers in the input are integers.
Output
Print the number of distinct virus distributions possible after seconds. The count can be very large, so print it modulo .