t = int(input())
for _ in range(t):
    a,b,c = map(int,input().split())
    if b == 0:
        print(0)
        continue
    temp = c//2
    if temp >= b and b != 0:
        print(3*b)
        continue
    ans = 3*temp
    b = b-temp
    if a == 0:
        print(ans)
        continue
    temp = b//2
    if temp >= a and a != 0:
        print(ans+3*a)
        continue
    print(ans+3*temp)
