
T = int(input())
for _ in range(T):
    a, b, c = map(int, input().split())
    res = min(c - int(c % 2 > 0), b * 2)
    rest_b = min(b, res // 2)
    second = min(b - rest_b - int((b-rest_b) % 2 > 0), a *2)
    res += rest_b + second + second // 2
    print(res)
