Flandre Scarlet(フランドール·スカーレット) is a vampire of The Embodiment of Scarlet Devil. But she is unfortunate because she is always in the undercroft.

The undercroft has so many rooms signed as room[1][1], room[1][2], ... room[N][M].

Today she wants to go from the room[1][1] to room[N][M]. Every room she can only go straight along the walls but some special rooms.

In the special rooms, she Flandre can go through it.

You can imagine that the length of every wall is 100.

Can you help Flandre to caculate out the minimum length she would go from the room[1][1] to room[N][M]?

You can reference the picture below.

For each case, you only need to print the minimum length that Flandre would go from (1, 1) to (N, M). Round to the nearest integer.