def smallest_distance(vertexes, dist):
    """Returns the smallest distance in dist where key is in vertexes."""
    smallest_k = vertexes[0]
    smallest_d = dist[smallest_k]
    for v in vertexes:
        if dist[v] < smallest_d:
            smallest_d = dist[v]
            smallest_k = v
    return smallest_k