for i in range(int(input())):
    a,b,c=map(int,input().split())
    profit=0
    if b==0 or a==b==c==0:
        print(0)
    else:
        while True:
            if b==0 or c==0 or c==1:
                break
            profit=3+profit
            b=b-1
            c=c-2
        while True:
            if b==0 or a==0 or b==1:
                break
            profit=profit+3
            a=a-1
            b=b-2
        print(profit)
                