t = int(input())

for i in range(t):
  pedras = 0
  a, b, c = [int(j) for j in input().split()]
  while (b >= 1 and c >= 2):
    b -= 1
    c -= 2
    pedras += 3
  while (a >= 1 and b >= 2):
    a -= 1
    b -= 2
    pedras += 3
  print(pedras)
	     				            	 				 	