def solve():
    pass

def main():
    t = int(input())

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

main()