k=0
limit = 8
Cs=list()
Bs=list()
As=list()
superlist=list()
while limit > k:
    k+=1
    As.append(list())
    Cs.append(list())
    
k=0
As[1].append(1)
As[2].append(1)
As[2].append(2)
k=1

def intersection(list1,list2):
    outlist = list()
    for x in xrange(len(list2)):
        if list1.count(list2[x]) == 0:
            pass
        else:
            if outlist.count(list2[x]) == 0:
                outlist.append(list2[x])
            else:
                pass
    return outlist

def subtraction(list1,list2):               ## list 2 from list 1
    outlist = list()
    for x in xrange(len(list1)):
        outlist.append(list1[x])
    for x in xrange(len(list2)):
        if outlist.count(list2[x]) == 0:
            pass
        else:
            outlist.pop(outlist.index(list2[x]))
    return outlist

while limit-1 > k:
    k+=1
    if As[k].count(k) == 0:
        As[k].append(k)
    else:
        pass
    for x in xrange(len(As[k-1])):
        for y in xrange(len(As[k-1])):
            if As[k-1][x] != 1 and As[k-1][y]:
                b=As[k-1][x]*As[k-1][y]
                if As[k].count(b) == 0:
                    As[k].append(b)
                    if superlist.count(b) == 0:
                        superlist.append(b)
                else:
                    pass
                As[k].sort()
    As[k].sort()
    
k=0
while limit-2 > k:
    k+=1
##    print(k," and ",k+1,"lists")
##    print(As[k])
##    print(As[k+1])
##    print("intersection")
##    print(intersection(As[k],As[k+1]))
##    print("subtraction")
##    print(subtraction(As[k+1],intersection(As[k+1],As[k])))
    r = subtraction(As[k+1],intersection(As[k+1],As[k]))
    if Bs.count(r[0]) == 0 and superlist.count(r[0]) == 0:
       Bs.append(r[0])


print(Bs)
print(len(Bs))


