def solve(a):
    ans = 0
    while a[1] >= 1 and a[2] >= 2:
        a[1] -= 1
        a[2] -= 2
        ans += 3
    while a[0] >= 1 and a[1] >= 2:
        a[0] -= 1
        a[1] -= 2
        ans += 3
    return ans


t = int(input())
for _ in range(t):
    a = [int(i) for i in input().split()]
    print(solve(a))