t = int(input())
while t:
    t -= 1
    a, b, c = [int(x) for x in input().split()]
    a1 = min(a, b // 2)
    k = b - (a1 * 2 )
    a2 = min(k, c // 2)
    
    
    
    a3 = min(b, c // 2)
    b -= (a3)
    a4 = min(a, b // 2)
    
    j1 = 3 * (a1 + a2)
    j2 = 3 * (a3 + a4)
    print(max(j1, j2))