t = int(input())
while t:
    a, b, c = [int(x) for x in input().split()]
    ans1, ans2 = 0, 0
    a1, b1, c1 = a, b, c
    act1 = min(a, b//2)
    ans1 += act1 + act1*2
    a -= act1
    b -= act1*2
    act2 = min(b, c//2)
    ans1 += act2 + act2*2
    act1 = min(b1, c1//2)
    ans2 += act1 + act1 * 2
    b1 -= act1
    c1 -= act1 * 2
    act2 = min(a1, b1 // 2)
    ans2 += act2 + act2 * 2
    print(max(ans1, ans2))
    t -= 1


