T = int(input())
query = []
for i in range(T):
    a,b,c = map(int,input().split())
    query.append((a,b,c))

def solve(a,b,c,ans=0):
    x = min(a//1,b//2)
    y = min(b//1,c//2)
    if x == 0 and y == 0 :
        return ans
    else:
        if x >= y :
            return solve(a-1,b-2,c,ans+3)
        else:
            return solve(a,b-1,c-2,ans+3)
for i in range(T):
    a,b,c = query[i]
    print(solve(a,b,c,ans=0))