Microscopic particles suspended on any fluid has a chaotic behavior since they do not stay at same location. Every moment they experience a number of collisions with fluid molecules from different directions. As a result of these collisions,the particle moves randomly as if it is confused all the time. In physics, this phenomenon is known as Brownian Motion named after the Scottish botanist Robert Brown who first described the phenomenon in 1827. Then, almost 80 years later, in 1905, Albert Einstein published a paper explaining Brownian Motion to establish the idea of existence of atoms and molecules. Now, more than 100 years later, with advancements of computer science, modeling the physical phenomena has become an important task for physicists. Since you are a great programmer and love to solve challenging problems, a group of physicists from your country came to you to help them solve this problem regarding Brownian Motion.
For a particle placed on the water surface, the physicists want to know the probability of the particle reaching another point on the surface after a certain amount of time. To model the scenario they imagined the surface of the fluid as a two-dimensional grid and each cell of the grid represents a point on the fluid surface. At each millisecond, the particle moves from one cell to any of its eight neighbor cells. The surface is a closed system, therefore, particles can not escape by crossing the boundary of the grid.
Initially, the surface is divided into an grid, where, . Cells are identified with the their row and column number as where . If a particle is located at , after a millisecond it must move to any of the following cells , , , , , , , . You will be given the initial position and final position . You have to find the probability of reaching from to after milliseconds, where, .
The probability can be represented as where are co-prime integers. Let, be an integer for which . You have to print .
The input consist of two lines.
First line of input contains two integers and separated by space.
Following line contains 4 integers separated by space.
Print a single integer, the probability of reaching initial to final cell after milliseconds as .
6 0 2 3 2 3
60 110 4 40 2 56
4 2 1 1 2 2
Note: The particle must move after a millisecond. It can not stay at the same cell for more than 1 millisecond.