for i in range(int(input())):
    a,b,c = map(int,input().split())
    co=0
    while(c>=2 and b>0):
        c-=2
        co+=2
        b-=1
        co+=1
    while(a>0 and b>=2):
        b-=2
        co+=2
        a-=1
        co+=1
    print(co) 