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

        while a > 0 and b > 1:
            a -= 1
            b -= 2
            ans += 3

        print(ans)

main()
