# BOJ 5369 - Offline

# Asteroid Field

## 문제

Plot a path through the asteroid field. Given a starting location, final destination, and a description of the asteroid fields plot a shortest path that takes you from the starting location to the final destination without running into any asteroids. The asteroid field is described using a mxm grid of characters with

- s: for starting location
- d: for final location
- -: for open space
- *: asteroid

Here is an example of a 4x4 grid.

    s*-*
    -*-*
    ----
    *-*d

Your ship can move up, down, left, and right (not diagonally). Each position in a mxm grid will be assigned an integer between 0 and m2-1 as follows.

## 입력

The first line will have a positive integer n representing the number of data sets. The first line of each data set will contain an integer m, followed by m lines, and each line will contain m characters. The character s will always be in the top left corner and d will always be in the bottom right corner.

## 출력

For each data set print the minimal number of moves needed to reach the destination or -1 if there is no solution.

## 예제 입력 1 복사

    2
    4
    s*-*
    -*-*
    --*-
    *-*d
    6
    s*---*
    -*-*--
    ---**-
    ***---
    --*-**
    *-*--d

## 예제 출력 1 복사

    -1
    18