for _ in range(int(input())):
    a,b,c=map(int,input().split())
    stones=0

    while(b>0) and c>1:
        b-=1
        c-=2
        stones+=3
    while(min(a,b))>0 and a>0 and b>1:
        a-=1
        b-=2
        stones+=3
    """elif max(a,b,c)==a or max(a,b,c)==b:
        while(min(a,b))>0 and a>0 and b>1:
            a-=1
            b-=2
            stones+=3
        while(min(b,c))>0 and b>0 and c>1:
            b-=1
            c-=2
            stones+=3"""


    print(stones)
