import re
import math
i=0
j=0
k=0
s=0
arr1 = []
arr2 = []
arr3 = []

n = int(input())

while j < n :
    s=0
    i=0
    arr = input()
    arr1 = re.split(' ' , arr)
    for i in range(3):
        arr1[i] = int(arr1[i])
    
    while arr1[1] > 0 and arr1[2] > 1:
        s+=3
        arr1[1]-=1
        arr1[2]-=2
    
    while arr1[1] > 1 and arr1[0] > 0 :
        s+=3
        arr1[1]-=2
        arr1[0]-=1
    
    
    print(s)
    j+=1






















