#TO MAKE THE PROGRAM FAST

''' ----------------------------------------------------------------------------------------------------  '''
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)
from collections import *
''' ----------------------------------------------------------------------------------------------------  '''




#FOR TAKING INPUTS

''' ----------------------------------------------------------------------------------------------------  '''
def li():return [int(i) for i in input().rstrip('\n').split(' ')]
def val():return int(input().rstrip('\n'))
def st():return input().rstrip('\n')
def sttoli():return [int(i) for i in input().rstrip('\n')]
''' ----------------------------------------------------------------------------------------------------  '''




#MAIN PROGRAM

''' ----------------------------------------------------------------------------------------------------  '''



for _ in range(val()):
    a,b,c = li()
    tot = 0
    while c>=2 and b:
        c-=2
        b-=1
        tot += 3
    while b>=2 and a:
        b -= 2
        a -= 1
        tot += 3
    print(tot)

''' ----------------------------------------------------------------------------------------------------  '''