t = int(input())
A = [list(map(int,input().split())) for i in range(t)]

for i in A:
    ans = 0
    a,b,c = i[0],i[1],i[2]
    ans += min(b, c//2)*3
    b -= min(b, c//2)
    ans += min(a, b//2)*3
    print(ans)