import sys
input = lambda:sys.stdin.readline()
MOD = 1000000007
ii = lambda: int(input())
si = lambda: input()
dgl = lambda: list(map(int, input()))
f = lambda: list(map(int, input().split()))
il = lambda: list(map(int, input().split()))
ls = lambda: list(input())
for _ in range(ii()):
    a,b,c=f()
    ans=0
    if c>b*2:
        ans+=b+b*2
        b=0
    else:
        ans+=(c//2)*2+c//2
        b-=c//2
    if a*2>b:
        ans+=(b//2)*2+b//2
    else:
        ans+=a+a*2
    print(ans)
