import sys; input = sys.stdin.readline from array import array def p(bm, c, b): if c == 0: return 1 if (key:=bm*17000+c*101+b) in mem: return mem[key] if bin(bm).count('1') < c != 0: mem[key] = 0; return mem[key] best = 0 for i in range(n): if bm&(1<= cost[i]: nxt = bm^(1<