n = int(input())
for i in range(n):
    a,b,c = list(map(int, input().split()))
    s=0
    if b -c//2 < 0:
        print(b*3)
        continue
    s+=c//2*3
    b-=c//2
    if a > b//2:
        s+=b//2*3
    else:
        s+=a*3
    print(s)