def perform_step(polymer: str, rules: dict) -> str:
    """
    Performs a single step of polymerization by performing all applicable insertions; returns new polymer template string
    """
    
    new = [polymer[i] + rules[polymer[i:i+2]] for i in range(len(polymer)-1)]
    new.append(polymer[-1])
    return "".join(new)