There is a cave of cells where each cell has a trap or is safe to land. From a cell , you can jump to cells or . Also, if number is special, then you can also jump from cell to cell where . A number can be special if .
You are given the following:
Note: Here, '#' represents an empty cell and '*' means a trapped cell.
Your task is to determine the minimum number of steps that you have to walk to reach the cell. Initially, you are at cell 1.
Input format
Output format
For each test case, print the minimum number of steps that you have to walk to reach the cell. Print the output in a separate line.
If it is not possible to reach the cell, then print "" without quotes.
Constraints
Note: For large input files, use faster input methods.
Note: 1-based indexing used below
1st Test Case:
In 3 jumps you can reach Nth cell. You can jump to , then to , then you could use
the special property and jump to .
2nd Test Case:
There is No Way! to reach the Nth cell.
3rd Test Case:
In 5 jumps you can reach Nth cell. You can jump to , then to , then to , then to , and then finally to ,