@classmethod
def permutations(cls, a, r=None, i=0):
    a = list(a)
    n = len(a)
    if (r is None):
        r = n
    res = []
    if ((r > n) or (i > r)):
        return res
    if (i == r):
        return [tuple(a[:r])]
    for j in range(i, n):
        (a[i], a[j]) = (a[j], a[i])
        res += cls.permutations(a, r, (i + 1))
    return res
@classmethod
def permutations(cls, a, r=None, i=0):
    a = list(a)
    n = len(a)
    if (r is None):
        r = n
    res = []
    if ((r > n) or (i > r)):
        return res
    if (i == r):
        return [tuple(a[:r])]
    for j in range(i, n):
        (a[i], a[j]) = (a[j], a[i])
        res += cls.permutations(a, r, (i + 1))
    return res