n = int(input())
for i in range(n):
    a,b,c = map(int,input().split())
    sum=(a+b+c)
    #print(a,b,c)
    if c:
        s = c//2
        if b>=s:
            c = c-(s*2)
            b = b-s
        else:
            c = c-(b*2)
            b = 0
    if b:
        s = b//2
        if a>=s:
            b = b-(s*2)
            a = a-s
        else:
            b = b-(a*2)
            a = 0

    print(sum-(a+b+c))


