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