for i in range(int(input())): a, b, c = map(int, input().split()) res = 0 tmp1 = min(a, c) res += tmp1*2 a -= tmp1 c -= tmp1 tmp2 = min(a, b) res += tmp2 a -= tmp2 b -= tmp2 tmp3 = b if b % 2 == 1: tmp3 -= 1 res += tmp3 print(res)