n=input()
def sol(a,b):
    s=0
    if b%2==0:
        if a>=b/2:
            s+=(b/2)+b
            a-=(b/2)
            b-=b
        else:
            s+=a+(a*2)
            a=0
            b-=(a*2)
    else:
        if a>=b/2:
            s+=(b/2)+(b-1)
            a-=(b/2)
            b-=(b-1)
        else:
            s+=a+(a*2)
            a-=0
            b-=(a*2)
    return [a,b,s]
def fr(a,b,c):
    s=0
    #print a,b,c
    a,b,s=sol(a,b)
    #print a,b,c
    #print s
    b,c,t=sol(b,c)
    #print a,b,c
    #print t
    s+=t
    return s
def ty(a,b,c):
    s=0
    #print a,b,c
    b,c,s=sol(b,c)
    ##print a,b,c
    #print s
    a,b,t=sol(a,b)
    #print a,b,c
    #print t
    s+=t
    return s
for _ in range(n):
    a,b,c=map(int,raw_input().split())
    print max(fr(a,b,c),ty(a,b,c))
    
