lst = []
while True:
    try:
        lst.append(input().split())
    except:
        break

for i in range(1,len(lst)):
    lst1 = list(map(int,lst[i]))
    sum = 0
    while True:
        if lst1[1]>=1 and lst1[2]>=2:
           sum+=3
           lst1[1]-=1
           lst1[2]-=2
        elif lst1[0]>=1 and lst1[1]>=2:
            sum+=3
            lst1[0]-=1
            lst1[1]-=2
        else:
            break
    print(sum)
    	 			  	 		 		  		 		  			