n = int(input())
for _ in range(n):
    s = 0
    a, b, c = list(map(int, input().split()))
    nc = c//2
    if b >= nc:
        s += nc
    else:
        s += b
    b -= nc
    if b >= 2:
        bc = b//2
        if a >= bc:
            s += bc
        else:
            s += a
    print(s*3)
