def solve(a, b, c, v):
    x = min(c//2, b)
    return x + min(a, (b-x)//2)


def main():
    for _ in range(int(input())):
        a, b, c = list(map(int, input().split()))
        print(3*solve(a, b, c, 0))


main()
