An integer N (1 ≤ N ≤ 300), representing some quantity or size.
An N x N grid of lowercase English letters.

### Example Input:
```
2
ab
ca
```

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