def solve(a, b, c):
    ans = 0
    for i in range(110):
        ta = a
        tb = b
        tc = c
        cnt = 0
        if ta >= i and tb >= 2*i:
            ta -= i
            tb -= 2*i
            cnt += i
        cnt += min(tb, tc//2)
        ans = max(ans, cnt*3)
    return ans


def main():
    t = int(input())
    for _ in range(t):
        a, b, c = [int(i) for i in input().split()]
        print(solve(a, b, c))


main()
