t = int(input())
while t>0:
    t = t-1
    a,b,c = map(int,input().split())
    stones= 0
    if a!=0 and b!=0 and c!=0:
        while c>=2 and b>=1:
            c = c-2
            b = b-1
            stones += 3
        while b>=2 and a>=1:
            b -= 2
            a -= 1
            stones += 3
    print(stones)