import sys,math,string,bisect
input=sys.stdin.readline
from collections import deque,defaultdict
L=lambda : list(map(int,input().split()))
Ls=lambda : list(input().split())
M=lambda : map(int,input().split())
I=lambda :int(input())
t=I()
for i in range(t):
    stones=0
    temp=L()
    while(temp[1]>0 and temp[2]>1):
        temp[1]-=1
        temp[2]-=2
        stones+=3
    while(temp[0]>0 and temp[1]>1):
        temp[0]-=1
        temp[1]-=2
        stones+=3
    print(stones)