from math import *
t = int(input())
while t>0:
    t-=1
    a,b,c = map(int,input().split())
    a1,b1,c1 = a,b,c
    x = min(a,b//2)
    x_ = min(2*a,(b//2)*2)
    a-=x
    b-=x_ 
    val = x+x_+min(b,c//2)+min(2*b,(c//2)*2)
    y = min(b1,c1//2)
    y_ = min(2*b1,(c1//2)*2)
    b1-=y 
    c1-=y_ 
    val1 = y+y_+min(a1,b1//2)+min(2*a1,(b1//2)*2)
    print(max(val,val1))
