def solve(): A,B,C=map(int,input().split()) ans=0 X=min(A,C); ans=2*X A-=X; C-=X ans+=2*(B//2); B%=2 ans+=min(A,B) return ans #================================================== import sys input=sys.stdin.readline write=sys.stdout.write T=int(input()) write("\n".join(map(str,[solve() for _ in range(T)])))