for _ in range(int(input())):
    a,b,c = map(int, input().split())
    mn = min(c//2,b)
    if mn==b:
        print(b*3)
    else:
        t = 0
        b-=c//2
        t += c//2 * 3
        mn = min(a,b//2)
        t += mn*3
        print(t)