# Virus Sniper - Indicative time limit: 1.0 seconds (reference environment: [environment and measurements](../../../docs/评测环境与性能.md)). - Actual time limit: twice the reference program's benchmark time on the slowest official input in the target environment, rounded up to a multiple of 0.5 seconds. Round up again if the platform requires a coarser unit. - Memory limit: 128 MB ## Story Yuri is testing a new warhead for the game's Virus sniper. Technicians first increase the initial intensity in several rectangles of a test field, then isolate a smaller rectangle to observe how the intensity spreads. Every experiment starts from the same initial record. Yuri wants results far into the future, and the region chosen for the next experiment depends on the previous output. ## Formal Problem Statement The field has $A$ rows and $B$ columns, initially with zero intensity everywhere. First perform $Q$ rectangle additions. An operation adds the integer $C$ to every cell of the closed rectangle with upper-left corner $(x_1,y_1)$ and lower-right corner $(x_2,y_2)$ . No spreading takes place during these operations. Each experiment isolates an $N$ by $M$ rectangle. Number its cells from $1$ to $d=NM$ in row order, top to bottom and left to right within each row. Probabilities depend on these relative cell indices and are reused in every experiment. For each source cell $i$ , five probabilities $p_{ij}=a_{ij}/b_{ij}$ correspond to itself, up, down, left, and right. At each integer time step, a transmission occurs with the given probability for each direction whose target remains inside the isolated rectangle. A transmission adds the source's entire current intensity to the target at the next time step. All transmissions are simultaneous, and existing intensity is retained. Newly added intensity can only spread starting with the following step. Directions leaving the rectangle are ignored, but their input pairs must still be read. All transmission trials are independent; the five probabilities need not sum to $1$ . There are $K$ queries, each specifying a nonnegative integer time $T$ . Find the expected intensity in every isolated cell at time $T$ . Each experiment restarts from the field after the rectangle additions, without inheriting any state from the previous experiment. Let $P=1000000009$ . Each expectation is a rational number whose denominator is not divisible by $P$ . For an expectation $r/s$ , output the unique integer $z$ satisfying $zs\equiv r\pmod P$ and $0\le z