<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def advance(self):
 """Follow the next rule if available. If we've run out of rules, reset the rules iterator. """

        try:
            return next(self._rules_iter)
        except InnerStopIteration:
            self._rules_iter = self._follow_rules()
            return StopIteration()
        except StopIteration:
            self._rules_iter = self._follow_rules()
            return final_rule