def solve(a,b,c):
    if b == 0  or max(a,b,c) == 1:
        return 0
    cnt = 0
    while(True):
        if(b>=1 and c >= 2):
            b -= 1
            c -= 2
            cnt += 3
        elif(a >= 1 and b>= 2):
            a -= 1
            b -= 2
            cnt += 3
        else:
            return cnt
    
t = int(input())
for _ in range(t):
    a,b,c = map(int,input().split())
    print(solve(a,b,c))