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