import collections


def get_pairs(vocab: dict) -> dict:
    """
    Get the pairs and their frequency of the vocabulary
    :param vocab: The input vocabulary
    :return pairs: Pairs and their frequency
    """
    pairs = collections.defaultdict(int)
    for word, freq in vocab.items():
        symbols = word.split()
        for i in range(len(symbols) - 1):
            pairs[symbols[i], symbols[i + 1]] += freq
    return pairs