def ii(): return int(input())
def fi(): return float(input())
def si(): return input()
def mi(): return map(int,input().split())
def li(): return list(mi())

import math 

t=ii()
for i in range(t):
    a,b,c=mi()
    ans=0 
    while c>=2 and b>=1:
        b-=1
        c-=2
        ans+=3
    while a>=1 and b>=2:
        a-=1
        b-=2
        ans+=3
    print(ans)