[snake in rungs]

Problem B -Snakes & Ladders

The childs game Snakes & Ladders is played on an m by n grid labelled with consecutive numbers in a zig-zag pattern from 1 to m*n. For example:
            12 11 10
             7  8  9
             6  5  4
             1  2  3
In addition there are a number of ladders which are directed edges connecting one grid position to another with a higher number, and snakes which are directed edges connecting one grid position to another with a lower number.

A player begins by placing his or her token on the position labelled 1. Whenever the token is placed at a particular position, if a snake or a ladder originates at that position, the token is moved immediately to the destination of that snake or ladder. There will be at most one snake or ladder connected (at either end) to any given position.

A die is thrown which yields a random integer uniformly distributed from the set {1,2,3,4,5,6}. This value is added to the position of the token and it is moved accordingly, if the position is on the grid. As described above, snakes or ladders originating from the new position should be followed.

The object of the game is to reach the position labelled m*n. Your job is to compute the expected number of die rolls necessary to win.

Input

The first line of input contains m and n (0 < m,n <= 10). Subsequent lines each contain a pair of integers o and d (1 <= o < m*n, 1 <= d <= m*n, o not equal to d ). A snake is denoted by o > d and a ladder by o < d.

Output

A single floating point number, rounded to two decimal places, giving the expected number of die rolls. You may assume that it is possible to win from any intermediate board position.

Sample Input

2 2
2 4

Sample Output

4.00