for _ in range(int(input())):
    A,B,C = list(map(int, input().split()))
    ans,asn = 0,0
    a,b,c = A,B,C
    k = min(a, b//2)
    b-=2*k; ans += 3*k
    k = min(b, c//2)
    ans += 3*k
    a,b,c = A,B,C
    k = min(b, c//2)
    b-=k; asn += 3*k
    k = min(a, b//2)
    asn += 3*k
    print(max(ans, asn))