input = raw_input

def answer():
    a, b, c = list(map(int, input().split(" ")))
    
    out = 0
    count2 = min(b, c // 2)
    out += (count2 * 3)

    b -= count2

    count1 = min(a, b // 2)
    out += (count1 * 3)
    return out


n = int(input())
for _ in range(n):
    out = answer()
    print(out)
