import sys

def memo(f, *args):
    cache = {}

    def memoized_f(*args):
        if args not in cache:
            cache[args] = f(*args)
        return cache[args]
    return memoized_f

inf = 2**30
@memo
def maxStone(a, b, c, res):
    if a < 0 or b < 0 or c < 0: return -inf
    if b == 0: return res
    left = -inf
    right = -inf
    if a==1 and b==1 and c==1: return res
    if b >= 2 and a >= 1:
        left = maxStone(a - 1, b - 2, c, res+3)
    if b >= 1 and c >= 2:
        right = maxStone(a, b-1, c-2, res+3)

    return max(left, right, res)


if __name__ == '__main__':
    sys.setrecursionlimit(50000000)
    n = int(raw_input())
    for i in range(n):
        a, b, c = map(int, str(raw_input()).split(" "))
        # print a, b, c
        print maxStone(a, b, c, 0)