for _ in range(int(input())):
    a,b,c = list(map(int,input().split()))

    count = 0

    maxC = c//2
    if(b > maxC):
        count += 3*maxC
        b = b - maxC
    else:
        count += 3*b
        b = 0

    maxB = b//2
    if(a > maxB):
        count += 3*maxB
    else:
        count += 3*a

    print(count)

