def wf_trace(D, str1, str2):
    """ Gets the list of operations performed by wagner_fischer().

    :param D: the memo matrix D used in wagner_fischer()
    :param str1: a string
    :param str2: the string that str1 was compared to
    :return: a list of -1, 0, +1 indicating insert, change, delete (from end to
             beginning of a and str2)
    """
    trace = []
    i, j = len(str1), len(str2)
    while i > 0 and j > 0:
        if D[i][j] == D[i - 1][j] + 1:
            trace.append(-1)
            i -= 1
        elif D[i][j] == D[i][j - 1] + 1:
            trace.append(+1)
            j -= 1
        else:
            trace.append(0)
            i -= 1
            j -= 1
    return trace