def rewrite(n, axiom, productions):
    """Produce the final list of commands after all replacements.

    Start by setting the axiom as the final string. With every iteration,
    replace each symbol with the string that is mapped to them in the
    productions dictionary.

    If the symbol is a constant that cannot be replaced, add it to the string
    as it is (this is the case for '+' and '-').

    For example: given an axiom F-F-F-F and a production F->FF-F, the first
    iteration would replace each 'F' in the axiom with the string 'FF-F',
    resulting in this new string: F->FF-F-F->FF-F-F->FF-F-F->FF-F. The second
    iteration would replace each 'F' in that new string with the string 'FF-F',
    and so on...
    """
    final_string = axiom
    for _ in range(n):
        s = ""  # String to be built
        for symbol in final_string:
            if symbol in productions:  # Replace
                s += productions[symbol]
            else:  # Constant
                s += symbol
        final_string = s
    return final_string