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