n = int(input())
for i in range(n):
    a,b,c = map(int,input().split())
    ans = 0

    c_1 = c//2
    if(b<=c_1):
        print(3*b)
    else:
        b = b-c_1
        b_1 = b//2
        if(a<=b_1):
            print((a+c_1)*3)
        else:
            print((b_1+c_1)*3)

    
    #b_and_c = min(b,c//2)

