t=int(input())
while(t):
    a,b,c=map(int,input().split())
    if(b!=0):
        z1 = c // 2
        c1 = min(z1, b)
        c2 = b - c1
        z2 = c2 // 2
        c3 = min(a, z2)
        ans1 = c1 * 1 + c1 * 2 + c3 * 1 + c3 * 2
        z3 = b // 2
        c4 = min(z3, a)
        c5 = b - (c4 * 2)
        z4 = c // 2
        c6 = min(z4, c5)
        ans2 = c4 * 1 + c4 * 2 + c6 * 1 + c6 * 2
        print(max(ans1,ans2))
    else:
        print(0)
    t=t-1
