for i in range(int(input())):
    k = list(map(int,input().split()))
    """
1) a-- b-- b--
    """
    ans=0
    while (k[0]>0 and k[1]>1) or (k[1]>0 and k[2]>1):
        ans+=3
        if (min(k[0],k[1]//2)>min(k[1],k[2]//2)):
            k[0]-=1
            k[1]-=2
        else:
            k[2]-=2
            k[1]-=1
    print(ans)
