def stone(a,b,c):
    count = 0
    if b == 0:
        return 0
    if a == 0:
        q = min(b,c)
        for i in range(q):
            if c >= 2 and b >= 1:
                count += 3
                if c < 2 or b < 1:
                    break
                c = c - 2
                b = b - 1
                
    if c == 0:
        q = min(a,b)
        for i in range(q): 
            if b >= 2 and a >= 1:
                count += 3
                if b < 2 or a < 1:
                    break
                b = b - 2
                a = a - 1
            
    if a != 0 or b != 0 or c!= 0:
        p = min(a,b,c)
        for i in range(p):
            if c >= 2 and b >= 1:
                count += 3
                if c < 2 or b < 1:
                    return
                c = c - 2
                b = b - 1
            if b >= 2 and a >= 1:
                count += 3
                if b < 2 or a < 1:
                    return
                b = b - 2
                a = a - 1
    return count

t = int(input())
for i in range(t):
    a,b,c = [int(i) for i in input().split()]
    ans = stone(a,b,c)
    print(ans)