import sys
import math as mt
input=sys.stdin.buffer.readline  
t=int(input())
#t=1
for __ in range(t):
    x,y,z=map(int,input().split())
    #n=int(input())
    #l=list(map(int,input().split()))
    mini=z//2
    if mini>y:
        mini=y
    y-=mini
    ans=2*mini+mini
   # print(1,mini)
    mini=y//2
    
    if mini>x:
        mini=x
    x-=mini
    #print(2,mini)
    ans+=(2*mini+mini)
    print(ans)