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