An integer H (1 ≤ H ≤ 6), representing some quantity related to rows.
An integer W (1 ≤ W ≤ 6), representing some quantity related to columns.
An integer K (1 ≤ K ≤ HW), representing some quantity.
A list of strings of length H, each containing W characters where each character is either '.' or '#'.

### Example Input:

```
2
3
2
..#
###
```

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