t = int(input())
for i in range(t):
    a,b,c = list(map(int,input().split()))
    sum = 0
    while (a >= 1 and b >= 2) or (b >= 1 and c >= 2):
        if a >= 1 and b >= 2:
            sum += 3
            a -= 1
            b -= 2
        if b >= 1 and c >= 2:
            sum += 3
            b -= 1
            c -= 2
    print(sum)