n = int(input())
s = list()
for x in range(n):
    s.append(input())
for x in s:
    r = 0
    x = x.split()
    a = int(x[0])
    b = int(x[1])
    c = int(x[2])

    k = min(b, c // 2)
    c -= k * 2
    b -= k
    r += k * 3

    k = min(a, b // 2)
    b -= k * 2
    a -= k
    r += k * 3
    
    print(r)