for _ in range(int(input())):
    a,b,c = list(map(int, input().split()))
    ans = 0
    if min(a, b//2) < min(b, c//2):
        k = min(a, b//2)
        a -= k
        b -= 2*k
        ans += 3*k
        k = min(b, c//2)
        b -= k
        c -= 2*k
        ans += 3*k
    else:
        k = min(b, c//2)
        b -= k
        c -= 2*k
        ans += 3*k
        k = min(a, b//2)
        a -= k
        b -= 2*k
        ans += 3*k
    print(ans)