for t in range(int(input())):
    a , b , c = map(int,input().split())
    z = c//2
    cnt1=0
    cnt2=0
    if z > b:
        cnt1+=(b*3)
        b = 0
    else:
        cnt1+=(z*3)
        b-=z
    y = b//2
    if y > a:
        cnt1+=(a*3)
    else:
        cnt1+=(y*3)
    print(cnt1)

