import sys, math sys.setrecursionlimit(10**8) sys.set_int_max_str_digits(0) INF = 10**18 MOD = 998244353 from bisect import bisect_left, bisect_right from collections import deque, defaultdict, Counter from itertools import product, combinations, permutations, groupby, accumulate from heapq import heapify, heappop, heappush def I(): return sys.stdin.readline().rstrip() def II(): return int(sys.stdin.readline().rstrip()) def IS(): return sys.stdin.readline().rstrip().split() def MII(): return map(int, sys.stdin.readline().rstrip().split()) def LI(): return list(sys.stdin.readline().rstrip()) def TII(): return tuple(map(int, sys.stdin.readline().rstrip().split())) def LII(): return list(map(int, sys.stdin.readline().rstrip().split())) def LSI(): return list(map(str, sys.stdin.readline().rstrip().split())) def GMI(): return list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split())) def kiriage(a, b): return (a+b-1)//b #def check(i:int, j:int): return 0 <= i < H and 0 <= j < W def solve2(N:int): X = 1 << (len(bin(N)) - 3) Y = N - X return X, Y def solve(N:int): if N == 0: return 0, 0 candi = [] N2 = list(format(N, 'b')) M = len(N2) X, Y = solve2(N) candi.append((X*Y, X, Y)) memo = [0]*M for i in range(M): if N2[i] == '1': memo[i] = 1<<(M - 1 - i) rui = list(accumulate(memo)) for i in range(M): if N2[i] == '1': keta = M - 1 - i if i != 0: sub = rui[i - 1] + ((1<