@classmethod
def createFromPair(cls, pair, n):
    """
        Given "pair"=[t,s], return the corresponding canonical factor.

        The list [t,s] should denote the generator a_{ts}.
        If a negative generator a^{-1} is represented,
            then return the permutation corresponding to Da^{-1}.

        >>> CanonicalFactor.createFromPair([5, 2], 7)
        CanonicalFactor([0, 4, 2, 3, 1, 5, 6])
        >>> CanonicalFactor.createFromPair([2, 5], 7)
        CanonicalFactor([6, 3, 1, 2, 0, 4, 5])

        """
    if pair[0] > pair[1]:
        lst = list(range(0, n))
        lst[pair[0] - 1] = pair[1] - 1
        lst[pair[1] - 1] = pair[0] - 1
    elif pair[0] < pair[1]:
        lst = [n - 1] + list(range(0, n - 1))
        lst[pair[0] - 1] = (pair[1] - 2) % n
        lst[pair[1] - 1] = (pair[0] - 2) % n
    else:
        lst = list(range(0, n))
    return cls(lst, size=n)
