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