from __future__ import division, print_function
import sys
af=[]
def print_bo(bo):
    af.append("YES" if bo else "NO")
le=sys.__stdin__.read().split("\n")[::-1]

def f():
    a,b,c=list(map(int,le.pop().split()))
    y=min(c//2,b)
    b-=y
    af.append(3*(y+min(b//2,a)))
for k in range(int(le.pop())):
    f()

print("\n".join(map(str,af)))
