t = int(input())
for i in range(t):
    s = list(map(int,input().split()))
    A = True
    total = 0
    while A:
        if (s[2] >= 2) and (s[1] >= 1):
            s[2] -= 2
            s[1] -= 1
            total += 3
        elif (s[1] >= 2) and (s[0] >= 1):
            s[1] -= 2
            s[0] -=1
            total += 3
        else:
            A = False
    print(total)
