def even_solve(A,B,C): ans = B+2*C C -= min(A,C) ans -= 3*(C//2) ans -= 3*(C%2) return ans def solve(): A,B,C = map(int,input().split()) if (A+B+C)%2: ans = 0 if A > 0: ans = max(ans,even_solve(A-1,B,C)) if B > 0: ans = max(ans,even_solve(A,B-1,C)) if C > 0: ans = max(ans,even_solve(A,B,C-1)) print(ans) else: print(even_solve(A,B,C)) T = int(input()) for i in range(T): solve()