Types: N: int, M: int, words: List[str], pairs: List[Tuple[int, int]]
Ranges: 1 ≤ N ≤ 100, 0 ≤ M ≤ 1,000, 1 ≤ len(words[i]) ≤ 10, 1 ≤ X_j, Y_j ≤ N
Addtl Info: words[i] consists of only lower-case letters