An integer N (1 ≤ N ≤ 100), representing some quantity or size.
An integer M (0 ≤ M ≤ 1,000), representing some quantity or size.
A list of N strings, each consisting of only lower-case letters and whose length is between 1 and 10, inclusive.
A list of M tuples, each containing two integers (X, Y) where 1 ≤ X, Y ≤ N.

### Example Input:
```
2
2
ab
ba
1 1
1 2
```

### Function Signature:
Write a function f(N, M, words, pairs) that takes in the input.
```python
def f(N: int, M: int, words: List[str], pairs: List[Tuple[int, int]]):
    '''
    N: an integer
    M: an integer
    words: a list of strings
    pairs: a list of tuples, each containing two integers
    '''
```