test = int(input())
while test>0:
    inp = input().split()
    x = int(inp[0])
    y = int(inp[1])
    z = int(inp[2])
    c = 0
    while z>1 and y>0:
        z -= 2
        y -= 1
        c +=3
    while x>0 and y>1:
        x -= 1
        y -= 2
        c += 3
    print(c)
    test -= 1