def METHOD_NAME(grammar, rule, fne):
    """
    Compute FIRST set for a given rule.
    The first set of a sequence of symbols u, written as First(u) is the set
    of terminals which start the sequences of symbols derivable from u.
    A bit more formally, consider all strings derivable from u. If u =>* v,
    where v begins with some terminal, that terminal is in First(u).
    If u =>* epsilon, then epsilon is in First(u).
    """
    first_set = []
    if rule not in fne:
        for productions in grammar[rule]:
            epsilon_found = True
            for production in productions:
                if production not in grammar:
                    # Terminal symbol
                    first_set.append((rule, production, productions))
                    epsilon_found = False
                    break
                else:
                    # Further productions
                    first_production = productions[0]
                    fne = METHOD_NAME(grammar, production, fne)
                    num_epsilon = 0
                    for _, sym, _ in fne[first_production]:
                        if sym != 'EPSILON':
                            first_set.append((rule, sym, productions))
                        else:
                            num_epsilon += 1
                    if num_epsilon == 0:
                        epsilon_found = False
                        break
            if epsilon_found:
                first_set.append((rule, 'EPSILON', productions))
        fne[rule] = first_set
    return fne