t = int(input())
for i in range(t):
    ans = 0
    a, b, c = map(int, input().split())
    first = min(b, c // 2)
    first += min(a, (b - first) // 2)
    second = min(a, b // 2)
    second += min(b - second * 2, c // 2)
    print(max(first, second) * 3)