def STONE(a,b,c):
    x=min(b,c//2)
    b-=x
    stone=3*x
    t=min(a,b//2)
    stone+=3*t
    print(stone)


t=int(input())
while(t>0):
    a,b,c=map(int,input().split())
    STONE(a,b,c)
    t-=1
    
      
