t = int(input()) 
o=[0]*t
p=[0]*t
r=[0]*t
for i in range(t):
    o[i],p[i],r[i] = [int(x) for x in input().split()]

for i in range(t):
    a=o[i]
    b=p[i]
    c=r[i]
    Max=0
    for x in range(min(101,a+1)):
        for y in range(min(101,int(c/2)+1)):
            if 2*x+y<=b and x+y>Max:
                    Max=x+y
    print(3*Max)