t = int(input())

def min(a, b):
    if(a < b):
        return a
    else:
        return b

for i in range(t):
    times = 0
    a, b, c = input().split(' ')
    a = int(a)
    b = int(b)
    c = int(c)

    times = min(b, int(c/2))
    b = b - times
    if(b > 0):
        times = times + min(a, int(b/2))

    print(times*3)

 					  				   	  		   	 			  	