from typing import List


def _greedy (lst : List[int], distances : List[List[int]]) -> List[int]:
    """
    This method returns a purely greedy solution.

    :param lst: The list of nodes to visit.
    :param distances: The distance matrix.
    :return: The nodes in the order in which they should be visited.
    
    """
    c_node = 0; sol : List[int] = []; options = list(lst)
    while len(options) > 0:
        options = sorted(options, key=lambda i: distances[c_node][i])
        c_node = options.pop(0)
        sol.append (c_node)

    return sol