n = int(input())

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