import sys; input=sys.stdin.readline def solve(x): y = x xcnt = x.bit_count() if xcnt == 1: return -1 for i in range(1, 40): y = x y >>= i y <<= i y |= 1<x and y.bit_count()