t = input()

def give_ans(a,b,c,i):
    x = 0
    if i<=a and 2*i<=b:
        x += 3*i
        b -= 2*i
        j = min(b, c/2)
        x += 3*j
    return x

for _ in range(t):
    a,b,c = map(int, raw_input().split())
    x = 0
    for i in range(a+1):
        x = max(x, give_ans(a,b,c,i))
    print (x)