import itertools
import random
def oneset(a,b,c):
for j in range(4):
if (a[j] + b[j] + c[j]) % 3 != 0:
return False
return True
def isnotset(field,card):
if len(field) < 2:
return True
for a,b in itertools.combinations(field,2):
if oneset(a,b,card):
return False
return True
def trial(cards):
field = []
for card in cards:
if isnotset(field,card):
field.append(card)
return field
allcard = list(itertools.product((0,1,2),repeat = 4))
ans = []
for _ in range(1000):
random.shuffle(allcard)
if len(ans) < len(trial(allcard)):
ans = trial(allcard)
print(len(ans),ans)