t = int(input())
for _ in range(t):
    a, b, c = map(int, input().split())
    stones = 0
    if c&1:
        stones += min(b*2, c-1)
    else:
        stones += min(b*2, c)
    stones += min(b, c//2)
    b -= min(b, c//2)
    if b&1:
        stones += min(a*2, b-1)
    else:
        stones += min(a*2, b)
    stones += min(a, b//2)
    b -= min(a, b//2)
    print(stones)