def triplet_pattern(t):
    """Convert an arbitrary 3-tuple into a string specifying the distinct elements."""
    if t[0] == t[1] == t[2]:
        return "AAA"
    if t[0] == t[1]:
        return "AAB"
    if t[1] == t[2]:
        return "ABB"
    return "ABC"