t=int(input())
for i in range(t):
    a,b,c=map(int,input().split())
    d=0
    while 1:
        if b>=1 and c>=2:
            b=b-1
            c=c-2
            d=d+3
        elif a>=1 and b>=2:
            a=a-1
            b=b-2
            d=d+3
        else:
            break
    print(d)