n = int(input())
for i in range(n):
    a,b,c=tuple(map(int,input().split()))
    t1=0
    d=min(a,b//2)
    b1=b-2*d
    t1+=3*d
    d=min(b1,c//2)
    t1+=3*d
    t2=0
    d=min(b,c//2)
    t2+=3*d
    b1=b-d
    d=min(a,b1//2)
    t2+=3*d
    print(t1 if t1>=t2 else t2)
