t = int(input())
r = []
for i in range(t):
    a,b,c = map(int,input().split())
    res = 0
    while b >= 1 and c >= 2:
        res += 3
        b -= 1
        c -= 2
    while a >= 1 and b >= 2:
        res += 3
        a -= 1
        b -= 2
    r.append(res)
for i in r:
    print(i)
