n = int(input())
for k in range(n):
    a,b,c = [int(i) for i in input().split()]
    ans = 0
    if b == 0:
        print(0)
    else:
        if b-c//2 >= 0:
            ans += c//2 + 2*(c//2)
            b -= c//2
        else:
            ans += b + 2*b
            print(ans)
            continue
        if a-b//2 >= 0:
            ans += b//2 + 2*(b//2)
        else:
            ans += a + 2*a
        print(ans)