t = input()
t = int(t)

while t > 0:
    ans = 0
    t -= 1
    a,b,c = map(int, input().split())
    while c >= 2 and b >= 1:
        c -= 2
        b -= 1
        ans += 3
    while b >= 2 and a >= 1:
        b -= 2
        a -= 1
        ans += 3
    print(ans)

 	 		 			 	 	    		 			 		   		