Lonely king#4557

Lonely king

1 second
122.174 megabytes
Very easy
prb4557-1

The lonely king wandered through the infinite chessboard. The sequence of its moves is known (up, down, left, right, up-left, etc.) the possible moves of the king are shown below.

Determine whether the king has visited the same field twice in his moves.

prb4557-2

Input

First line contains the number of king's moves (0 \le n \le 1000). Next lines give the directions of king's moves: line number i + 1 gives the king's direction at the -th move.

Output

Print a single number - the number of the move when the King first comes to some cell for the second time. If no such event happens, print "Ok" message in the first line (without quotes), and in the second line print the Manhattan distance between the starting and ending points of king's travel path.

Manhattan distance is a distance between the points with coordinates (x_1, y_1) and (x_2, y_2) that evaluates by the formula: d = |x_2 - x_1| + |y_2 - y_1|.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading