def f(s, m):
if s>=301:
return m%2==0
if m==0:
return 0
h=[f(s+3, m-1), f(s*5, m-1)]
if (m-1)%2==0:
return any(h)
else:
return all(h)
print([s for s in range(1, 301) if not(f(s, 2)) and (f(s, 2) or f(s, 4))])
def f(a, b, m):
if a+b>=275:
return m%2==0
if m==0:
return 0
h=[f(a+3, b, m-1), f(a+7, b, m-1), f(a*4, b, m-1), f(a, b+3, m-1), f(a, b+7, m-1), f(a, b*4, m-1)]
if (m-1)%2==0:
return any(h)
else:
return all(h)
print([s for s in range(1, 217) if not(f(58, s, 2)) and f(58, s, 2) or f(58, s, 4)])