t = int(input())
for i in range(t):
    x = input().split()
    s = 0
    for j in range(3):
        x[j] = int(x[j])
    a = x[0]
    b = x[1]
    c = x[2]
    while b>=1 and c>=2:
        b -=1
        c-=2
        s+=3
    while a>=1 and b>=2:
        a-=1
        b-=2
        s+=3
    print(s)            
