n = int(input())
for i in range(n):
    a, b, c = map(int, input().split())
    pick1 = min(b, c // 2)
    b -= pick1
    pick2 = min(a, b // 2)
    print(3 * (pick1 + pick2))

 	    		      		   	  	 	