nb = int(input())
L = []
for i in range(nb):
    L.append(input())
for i in range(len(L)):
    L[i]= L[i].split()
for i in range(len(L)):
    for j in range(len(L[i])):
        L[i][j] = int(L[i][j])
for i in range(len(L)):
    count = 0
    while L[i][1]>0 and L[i][2]>1:
        L[i][1] = L[i][1]-1
        L[i][2] = L[i][2]-2
        count +=3
    while L[i][1]>1 and L[i][0]>0:
        L[i][0] = L[i][0]-1
        L[i][1] = L[i][1]-2
        count+=3
    print(count)    
        
    