Byteland is a beautiful country with $n\times m$ cities, conveniently labeled with $1,2,3,...,n\times m$. The map of Byteland can be represented as a matrix with $n$ rows and $m$ columns, and the label of city $(i,j)$ is $id[i][j]$.
Byteasar is proud of Byteland's advanced traffic system. The traffic system of Byteland can be compressed to $e$ information. Each information contains $9$ integers $L,R,A,B,dx,C,D,dy,w$, which can be decoded using the program below:
for(i = L;i <= R;i ++)
for(x = A;x <= B;x += dx)
for(y = C;y <= D;y += dy)
addedge(i, id[x][y], w);
where $addedge(x, y, z)$ means adding an one-way edge with length $w$, which starts at the $x$-th city and ends at the $y$-th city.
Byteasar lives in $(sx,sy)$, he wants to know the shortest path from his position to every city, can you help him?