t = int(input())
for i in range(t):
    s1, s2, s3 = map(int, input().split())
    s = 0
    for k1 in range(s1):
        if (s2-2*k1>=0):
            k2 = min(s2-2*k1, s3//2)
            if (s < 3*(k1+k2)):
                s = 3*(k1+k2)
    print(s)
        
