#!/usr/bin/python3

class gf4():

    def __init__(self, n):
        if n in range(0,4):
            self.n = n
        else:
            raise Exception(str(n), "out of range")

    def __add__(self, a2):
        return self.n ^ a2.n

    def __int__(self):
        return self.n

    def __str__(self):
        return "#" + str(self.n)

    def __mul__(self, f2):
        if self.n == 0 or f2.n == 0: return gf4(0)
        elif self.n == 1: return f2
        elif f2.n == 1: return self
        elif self.n != f2.n: return gf4(1)
        elif self.n == 2: return gf4(3)
        elif self.n == 3: return gf4(2)
        else: raise Exception("WTF")

class triple():
    names = [ "a", "b", "c", "d", "e", 
              "f", "g", "h", "i", "j",
              "k", "l", "m", "n", "o",
              "p", "q", "r", "s", "t", "u" ]
    def __init__(self, a, b, c):
        self.t = [a,b,c]
    def __add__(self, a2):
        return triple(*[self[i] + a2[i] for i in range(3)])

    def __getitem__(self, n):
        if n in range(0,3):
            return self.t.__getitem__(n)
        else:
            raise Exception("The index was " + n)

    def index(self):
        n = int(self[0]) * 16 + int(self[1]) * 4 + int(self[2])
        if int(self[0]) == 0:
            if int(self[1]) == 0:
                n += -1
            else:
                n += -3
        else:
            n += -11
        return n
        
    def __str__(self):
        # print("stringizing <" + str(self.t[0]) + str(self.t[1]) + str(self.t[2]) + ">")
        if self.ok():
#            return "!!" + str(self.index())
            return triple.names[self.index()]
        else:
            return "<" + str(self[0]) + ","  + str(self[1]) + "," + str(self[2]) + ">"

    def ok(self):
        for i in self.t:
#            print("-- " + str(i))
            if int(i) == 1: return True
            elif int(i) == 0: continue
            else: return False

    def scale(self, sc):
        return triple(*[self[i] * gf4(sc) for i in range(3)])

    def variants(self):
        return [ self.scale(i) for i in [1,2,3] ]

    def all_sums(self, a2):
        return [ a + b for a in self.variants() 
                       for b in a2.variants() if (a+b).ok() ]


if __name__ == '__main__':
    def elts():
        return [ gf4(i) for i in range(4) ]

    def triples():
        return [ triple(a,b,c) for a in elts() for b in elts() for c in elts() if triple(a,b,c).ok() ]

    t = triples()
    pairs = {}

#    for i in t:
#        print(str(i))
#    from sys import exit
#    exit(0)

    cards = []
    for i in t:
#        print("i: ", str(i))
        for j in t:
#            print("  j: ", str(j))
            if i == j: continue
            if (str(i),str(j)) in pairs or (str(j),str(i)) in pairs: continue
            ct = [ i, j, *i.all_sums(j) ]
            card = [ str(a) for a in ct ]
            for a in card:
                for b in card:
                    pairs[(a,b)] = 1
                    pairs[(b,a)] = 1
            card.sort()
            cards += [ card ]
            print("".join(card))

#    print(a)
#    print(a.scale(2))
#    print(a.scale(3))
