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