t=int(raw_input())
for i in range(t):
    a,b,c=map(int,raw_input().split())
    t=0
    while a+b>4 and a>0:
       t+=3
       a-=1
       b-=2
    while b+c>=3 and b>0:
        t+=3
        b-=1
        c-=2
    print t

