def countStones(a, b, c, cache):
    if (a, b, c) in cache:
        return cache[(a, b, c)]
    left, right = 0, 0
    if a >= 1 and b >= 2:
        left = 3 + countStones(a - 1, b - 2, c, cache)
    if b >= 1 and c >= 2:
        right = 3 + countStones(a, b - 1, c - 2, cache)
    cache[(a, b, c)] = max(left, right)
    return cache[(a, b, c)]
t = int(input())
for _ in range(t):
    a, b, c = map(int, input().split())
    cache = {}
    print(countStones(a, b, c, cache))
