for _ in range(int(input())):
    a,b,c=[int(i) for i in input().split()]
    nd=0
    while b>=1 and c>=2:
        b=b-1
        c=c-2
        nd+=3
    #print(nd,a,b)
    while a>=1 and b>=2:
        a=a-1
        b=b-2
        nd+=3
    print(nd)
