T = int(input()) ABC = [list(map(int, input().split())) for _ in range(T)] for a, b, c in ABC: ans = 0 cnt = min(a, c) ans += cnt*2 a-=cnt c-=cnt cnt = b//2 ans += cnt*2 b%=2 cnt = c//2 ans += cnt c%=2 if a>0 and b>0: ans += 1 print(ans)