import sys
input = sys.stdin.readline

def r1():
    return int(input())
def rm():
    return map(int, input().split())

t = r1()
for i in range(t):
    a, b, c = rm()

    x = min(b, c // 2)
    r = 3*x
    b -= x

    x = min(a, b // 2)
    r += 3*x

    print(r)
