from typing import List
from typing import Mapping


def route_distance(route: List[str],
                   distances: Mapping[str, Mapping[str, int]]) -> int:
    """The cumulative distance following the given route."""
    distance = 0
    previous = None
    for current in route:
        if not previous:
            previous = current
            continue
        distance += distances[previous][current]
        previous = current
    return distance