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