h1=int(input())
a=[]
for i in range(h1):
    c=0
    x,y,z=map(int,input().split())
    h=int(z/2)
    if h<=y:
        c=c+h*3
        y=y-h
    else:
        c=c+y*3
        y=0
    h=int(y/2)
    if h<=x:
        c=c+h*3
    else:
        c=c+x*3
    a.append(c)
for i in range(h1):
    print(int(a[i]))