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