n = int(input())

for i in range(n):
    result = 0
    a,b,c = list(map(int, input().split()))
    first = c // 2
    firsttt = min(b, first)
    result += firsttt*2 + firsttt
    b -= firsttt
    second = b // 2
    secondtt = min(a, second)
    result += secondtt*2 + secondtt
    print(result)
