t = int(input())
for test in range(t):
    a1,b1,c1 = map(int, input().split(" "))
    res = 0
    res1 = min(a1, b1//2)
    a = a1 - res1
    b = b1 - res1*2
    res2 = min(b, c1//2)
    res = res1*3 + res2*3
    res1 = min(b1,c1//2)
    b1 -= res1
    res2 = min(a1,b1//2)
    res = max(res, res1*3 + res2*3)
    print(res)