t = int(input(''))
for _ in range(t):
    a = input('').split(' ')
    b = int(a[1])
    c = int(a[2])
    a = int(a[0])
    if(b == 0):
        print(0)
        continue
    ans = 0
    if(c//2 <= b):
        ans = 3*(c//2)
        b = b - c//2
        if(b >= 2):
            if(a >= b//2):
                ans = ans+ 3*(b//2) 
            else:
                ans = ans+ 3*(a)
    else:
        ans = b + b*2
    print(ans)