def _transpose(x):
    """The transpose of a matrix

    :param x: an NxM matrix, e.g. a list of lists
    :returns: a list of lists with the rows and columns reversed
    """
    return [[x[j][i] for j in range(len(x))] for i in range(len(x[0]))]