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])
    while c >= 2 and b >= 1:
        c -= 2
        b -= 1
        r += 3
    while b >= 2 and a >= 1:
        b -= 2
        a -= 1
        r += 3
    print(r)
