import os
import sys
from collections import defaultdict as ddic, Counter, deque
from itertools import combinations, permutations, product

FAST_INPUT = 0
if FAST_INPUT:
    from atexit import register
    from io import BytesIO

    sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
    sys.stdout = BytesIO()
    register(lambda: os.write(1, sys.stdout.getvalue()))

rr = lambda: sys.stdin.readline().rstrip('\r\n')
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
MOD = 10**9 + 7

DEBUG = 0
if DEBUG:
    import random
    random.seed(0)
    ri = random.randint
    
#####

def solve(A):
    x,y,z = A
    ans = 0
    for alpha in xrange(101):
        for beta in xrange(101):
            # alpha 2alpha+beta 2beta
            if x >= alpha and y >= 2*alpha+beta and z>=2*beta:
                ans = max(ans, alpha+beta)
    return 3*ans
    





    
    ###


T = rri()
for tc in xrange(T):
    A = rrm()
    print solve(A)
