import sys readline=sys.stdin.readline from functools import lru_cache @lru_cache(maxsize=None) def grundy(bit): if bit==0: return 0 se=set() for i in range(bit.bit_length()): if bit&1<