t = int(input())
for a in range(1,t+1):
    n=0
    a,b,c=[int(x) for x in input().split()]
    if (b!=0):
        while (c>=2 and b>=1):
            c=c-2
            b=b-1
            n=n+3
        while (b>=2 and a>=1):
            b=b-2
            a=a-1
            n=n+3
        print(n)
    else:
        print(n)
        