------
## 最终结论
```python
def max_coins(N):
    # Mr. Chanek's strategy to maximize his coins
    coins = 0
    turn = 0  # 0 for Mr. Chanek, 1 for opponent
    
    while N > 0:
        if N % 2 == 0:  # If N is even
            take_half = N // 2
            if turn == 0:  # Mr. Chanek's turn
                coins += take_half
            N -= take_half
        else:  # If N is odd
            if turn == 0:  # Mr. Chanek's turn
                coins += 1
            N -= 1
        
        turn = 1 - turn  # Switch turns
    
    return coins

T = int(input())
results = []
for _ in range(T):
    N = int(input())
    results.append(max_coins(N))

print('\n'.join(map(str, results)))
```