testCases = int(input())
for t in range(testCases):
    a, b, c = tuple(map(int, input().split(" ")))

    num_op_y = min(b, c // 2)
    num_op_x = min(a, (b - num_op_y) // 2)

    print(3*(num_op_x + num_op_y))
 	 		 	   		  		  	 		 	 	  	 	