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