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