def print_matrix(x, y, A):
    """Print the matrix with the (0,0) entry in the top left
    corner. Will label the rows by the sequence and add in the
    0-row if appropriate."""
    if len(x) == len(A):
        print('%5s' % ' '),
    else:
        print('{} {}'.format(' ', '*')),
        y = '*' + y
    for c in x:
        print('{}'.format(c)),
    for j in range(len(A[0])):
        print('{}'.format(y[j])),
        for i in range(len(A)):
            print('{}'.format(A[i][j])),
