Canonicalized Input Description:

An integer W (3 ≤ W ≤ 500), representing some width.
An integer H (3 ≤ H ≤ 500), representing some height.
H lines each containing W characters from the set {'.', '#', 's', 'g', '*'}. The characters in each line are not separated by spaces.

### Example Input:

```
8 6
########
#..##g.#
#*#.*#.#
#......#
#*s#*.*#
########
```

### Function Signature:
Write a function f(W, H, grid) that takes in the input.
def f(W: int, H: int, grid: List[str]):
    ''' 
    W: an integer 
    H: an integer 
    grid: a list of strings
    '''