import sys input = sys.stdin.readline T = int(input()) for _ in range(T): A, B, C = map(int, input().split()) ans = 0 v02 = min(A, C) ans += 2 * v02 A, C = A - v02, C - v02 v11 = B // 2 ans += 2 * v11 B %= 2 v01 = min(A, B) ans += v01 A, B = A - v01, B - v01 v22 = C // 2 ans += v22 C %= 2 print(ans)