test = int(input())
for i in range(test):
    (a,b,c) = (map(int,input().split()))
    total = 0
    if b == 0:
        print(0)
    else:
        while b > 0 and c > 0:
            b -= 1
            c -= 2
            total += 3
            if c == 1:
                break
        while a > 0 and b > 0:
            a -= 1
            b -= 2
            total += 3
            if b == 1:
                break
        print(total)