from itertools import permutations

class Medals:
    GOLD = 1
    SILVER = 2
    BRONZE = 3
    NONE = 0


medals = [Medals.GOLD, Medals.SILVER, Medals.BRONZE, Medals.NONE, Medals.NONE]

for A, B, C, D, E in set(permutations(medals)):
    if not (A != Medals.GOLD and B != Medals.SILVER) and \
       not (D != Medals.SILVER and E != Medals.BRONZE) and \
       not (C > Medals.NONE and D == Medals.NONE) and \
       not (A > Medals.NONE and C == Medals.NONE) and \
       not (D > Medals.NONE and E > Medals.NONE):
            print("A:%s B:%i C:%i D:%i E:%i" % (A, B, C, D, E))