t = int(input())
for i in range(t):
    a, b, c = list(map(int, input().split()))
    ans = 0
    temp = min(b, c//2)
    ans += temp+temp*2
    b-=temp
    temp = min(a, b//2)
    ans += temp + temp*2
    print(ans)