q = int(input())
for tmp in range(q):
    
    a,b,c = list(map(int,input().split()))
    k = 0
    k += 3 * min(b,c//2)
    b -= min(b,c//2)
    c -= 2 * min(b,c//2)
    k += 3 * min(a,b//2)

    print(k)
