t=int(input())
for _ in range(t):
    a,b,c=map(int,input().strip().split())
    count=0
    while b>=1 and c>=2:
        c=c-2
        b=b-1
        count=count+3
    while b>=2 and a>=1:
        b=b-2
        a=a-1
        count=count+3
    print(count)