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


