# Minimum moves to find the Ball in the Large Grid

Given N*M grid in which one cell contains a ball and all other cells are empty in all other boxes i am provided with one of these 8 directions towards the right position of ball.These are :

1.Exactly Above it
2.Exactly Below it
3.Exactly To the Right
4.Exactly To the Left
5.In the Top Right Region
6.In the Bottom Right Region
7.In the Top Left Region
8.In the Bottom Left Region


How to find the ball in minimum moves.So we need to tell minimum moves required to find the ball.

Note : N and M can go upto 10^19 so we cant make a 2D Grid and then solve.

EXAMPLE : If N=3 and M=3 then here minimum moves is 1

-