import sys
input = sys.stdin.readline

t = int(input())
# print(t)

for _ in range(t):
    a,b,c = list(map(int,input().split()))
    # print (a,b,c)
    maxi = 0
    for x in range(a+1):
        for y in range(c//2+1):
            if (2*x+y<=b) and (3*x+3*y>maxi):
                maxi = 3*x+3*y
    print(maxi)