<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _resolve_atomtypes(topology):
 """Determine the final atomtypes from the white- and blacklists. """

    for atom in topology.atoms():
        atomtype = [rule_name for rule_name in atom.whitelist - atom.blacklist]
        if len(atomtype) == 1:
            atom.id = atomtype[0]
        elif len(atomtype) > 1:
            raise FoyerError("Found multiple types for atom {} ({}): {}.".format(
                atom.index, atom.element.name, atomtype))
        else:
            raise FoyerError("Found no types for atom {} ({}).".format(
                atom.index, atom.element.name))