t = int(input())

for _ in range(t):
    a, b, c = map(int, input().split())
    ca, cb, cc = a, b, c
    
    q = min(ca, cb//2)
    ca -= q
    cb -= 2*q
    ans1 = 3*q + 3*min(cb, cc//2)
 
    q = min(b, c//2)
    c -= 2*q
    b -= q
    ans2 = 3*q + 3*min(a, b//2)
    
    print(max(ans1, ans2))