There is a field divided into a grid of $H$ rows and $W$ columns.
The square at the $i$\-th row from the north (top) and the $j$\-th column from the west (left) is represented by the character $A_{i, j}$. Each character represents the following.
* `.` : An empty square. Passable.
* `#` : An obstacle. Impassable.
* `>`, `v`, `<`, `^` : Squares with a person facing east, south, west, and north, respectively. Impassable. The person's line of sight is one square wide and extends straight in the direction the person is facing, and is blocked by an obstacle or another person. (See also the description at Sample Input/Output $1$.)
* `S` : The starting point. Passable. There is exactly one starting point. It is guaranteed not to be in a person's line of sight.
* `G` : The goal. Passable. There is exactly one goal. It is guaranteed not to be in a person's line of sight.
Naohiro is at the starting point and can move one square to the east, west, south, and north as many times as he wants. However, he cannot enter an impassable square or leave the field.
Determine if he can reach the goal without entering a person's line of sight, and if so, find the minimum number of moves required to do so.
## Constraints
* $2 \leq H, W \leq 2000$
* $A_{i,j}$ is `.`, `#`, `>`, `v`, `<`, `^`, `S`, or `G`.
* Each of `S` and `G` occurs exactly once among $A_{i, j}$.
* Neither the starting point nor the goal is in a person's line of sight.
## Input
The input is given from Standard Input in the following format:
$H$ $W$
$A_{1,1}A_{1,2}\dots A_{1,W}$
$A_{2,1}A_{2,2}\dots A_{2,W}$
$\vdots$
$A_{H,1}A_{H,2}\dots A_{H,W}$
[samples]