from sys import stdin, stdout

for i in range(int(stdin.readline())):
    a, b, c = stdin.readline().split()
    a, b, c = int(a), int(b), int(c)

    stones = 0

    if b >= c // 2:
        b -= c // 2
        stones += c // 2
        stones += (c // 2) * 2
    else:
        stones += b
        stones += b * 2
        b = 0
    if a >= b // 2:
        stones += b // 2
        stones += (b // 2) * 2
    else:
        stones += a
        stones += a * 2

    stdout.write(str(stones) + "\n")
