t = int(input())
for _ in range(t):
    a,b,c = map(int,input().split())
    if b==0:
        print(0)
        continue
    cnt=0
    br = c//2
    if br>b:
        cnt=b+b*2
        b=0
    else:
        cnt = br+br*2
        b-=br
    if b>0:
        ar=b//2
        if ar>a:
            cnt+=a+a*2
            a=0
        else:
            cnt += ar+ar*2
            a-=ar
    print(cnt)
