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