n = int(input())
for i in range(n):
    a, b, c = map(int, input().split())
    first_ans = min(a, b // 2) + min(b - min(a, b//2) * 2, c // 2)
    second_ans = min(b, c//2) + min(a,(b - min(b // 2, c)) // 2)
    print(max(first_ans, second_ans) * 3)