def foo(a, b, c):
    stones = 0

    while b > 0 and c > 1:
        c -= 2
        b -= 1
        stones += 3

    while a > 0 and b > 1:
        b -= 2
        a -= 1
        stones += 3
    return stones

if __name__ == '__main__':
    t = int(input())

    while t > 0:
        a, b, c = map(int, input().split())
        print(foo(a, b ,c))
        t-= 1
