n=int(input())
for i in range(n):
    a,b,c=map(int,input().strip().split())
    su=0
    while(b!=0):
        if c>=2:
            su+=3
            c=c-2
            b=b-1
        else:
            break
    while(a!=0):
        if b>=2:
            su+=3
            b=b-2
            a=a-1
        else:
            break
    print(su)
