for _ in range(int(input())):
    a, b, c = map(int, input().split())
    stones = 0
    if c//2 >= b:
        stones += 3*b
    else:
        stones += (c//2) * 3
        b -= c//2
        if b//2 >= a:
            stones += 3*a
        else:
            stones += (b//2) * 3
    print(stones)