def transition_function(self, qi, u):
        """
        :param qi: int: current state, qi ∈ Q
        :param u:str: transition character u ∈ S
        :returns Q': int :  δ(qi, u) = q
        """
        try:
            return self.transition[qi][u]
        except KeyError:
            if u in self.alphabet:
                try:
                    return self.transition[qi]['*']
                except KeyError:
                    return None
            return None