def build_scoring_matrix(alphabet, diag_score, off_diag_score, dash_score):
    """ set, int, int, int -> dict of dict
    Takes a set of characters for the alphabet and three scores.  Returns a
    dictionary of dictionaries whose entries are indexed pairs of characters
    alphabet plus '-'.
    """

    letters = list(alphabet)
    letters.append('-')

    scoring_matrix = {}

    for letter_x in letters:
        scores = {}
        for letter_y in letters:
            if '-' in letter_x + letter_y:
                scores[letter_y] = dash_score
            elif letter_x == letter_y:
                scores[letter_y] = diag_score
            else:
                scores[letter_y] = off_diag_score
        scoring_matrix[letter_x] = scores
    return scoring_matrix